How do you flush/clear the entire AppFabric Cache?
-
jeudi 5 mai 2011 18:08I'm looking for a way to flush all data out of a specific Cache.
http://www.IActionable.com - Game Mechanics as a Service
Toutes les réponses
-
vendredi 6 mai 2011 10:56
You can find the API from here: http://msdn.microsoft.com/en-us/library/microsoft.applicationserver.caching.datacache_members(v=WS.10).aspx.
Some methods are limited support in Windows Azure AppFabric Cache, please see http://msdn.microsoft.com/en-us/library/gg278350.aspx.
Since currently Windows Azure AppFabric Cache does not support named region, you might use GetSystemRegions method to get the default region and then call ClearRegion method to clear cached objects in that region.
-
vendredi 6 mai 2011 17:09
Unfortunately that solution does not work.
Calling GetSystemRegions or ClearRegion throws an exception saying that it is not supported by the cache.
http://www.IActionable.com - Game Mechanics as a Service
-
lundi 9 mai 2011 10:46Can you describle the scenario where flusing all data from a cache is required? Currently this is not supported.
-
lundi 9 mai 2011 15:32
When I'm unit testing and benchmarking code I would like to start with what I know is a completely empty cache.
It would also be nice to be able to test code against the scenario of my cache data being completely lost and making sure the system can recover quickly.
Whenever I change the key structure/pattern I would like to flush it to ensure there aren't any collisions by removing all the items.
I would also like control over the cache in case production bugs have introduce some abnormalities in the data or aren't refreshing properly.
http://www.IActionable.com - Game Mechanics as a Service -
lundi 9 mai 2011 15:50
You could always append a version number or some other prefix/suffix to your cache keys (e.g. itemOne-v1, itemTwo-v1). Then, whenever you need to clear the cache, you increment the version number or change the suffix (e.g. item0ne-v2, itemTwo-v2). This ensures that after the change, you will always get a cache miss and, because the eviction policy of the cache removes least-recently-used items, any new items added to the cache will eventually replace old items.
- Marqué comme réponse Wenchao ZengModerator jeudi 12 mai 2011 07:14
- Non marqué comme réponse IActionable jeudi 4 août 2011 14:23
-
jeudi 4 août 2011 13:54
"Can you describle the scenario where flusing all data from a cache is required?"
I don't mean to be rude but isn't this just the most ridiculous question? Isn't it akin to describing the scenario for choosing to jump from a skyscraper? Maybe we like base jumping, or perhaps it's burning, or it's suicide, or we didn't know it was so high, or we were trying to clear the gap onto the other roof, or we thought god might save us if we beleived hard enough, or it was so windy i figured i would blow back up and be ok...etc. etc. etc.
Isn't it enough that this guy just described a requirement for it and that therefore the scenario exists?
The first thing i needed was to clear down my cache after tinkering with it. Why? Because i'm just plain lazy sometimes and figured i'd like to start again, mmm not unlike my unit tests too.
Cheers
J
-
jeudi 4 août 2011 14:05
Thanks for the support :)Isn't it enough that this guy just described a requirement for it and that therefore the scenario exists?
You could always append a version number or some other prefix/suffix to your cache keys (e.g. itemOne-v1, itemTwo-v1). Then, whenever you need to clear the cache, you increment the version number or change the suffix (e.g. item0ne-v2, itemTwo-v2). This ensures that after the change, you will always get a cache miss and, because the eviction policy of the cache removes least-recently-used items, any new items added to the cache will eventually replace old items.
I tried to go down this path and it just isn't manageable. I don't like the idea of someone needing to change a production environment config or re-deploy a role in order to modify this 'magic' key. In a perfect world, I would prefer to have this has an option in the Management Portal as button that flushes everything on demand.
http://www.IActionable.com - Gamification and Analytics Platform
-
jeudi 4 août 2011 14:09
Now here's a cracking example scenario. All the serialized instances in the cache are no longer valid for the updated code I'm about to release as out of neccesity i had to break the contract. I need that cache splatting.
-
vendredi 28 octobre 2011 01:26
Here's another scenario, if you need it:
I load the cache with the totality of a set A that represents my universe of values.
Then one node goes down in a non-HA cluster taking with it all values hashed to that node.
Now my universe and cache is corrupt and I need to reload it.
So, I would a) flush it and b) reload it
The Flush() is simply not available. And, no, Restart-CacheNode or Restart-CacheCluster won't get me there and may restart other caches that need to be unaffected by the corruption.
And stop giving these over-engineering answers like: "create your own namespace" and "enumerate the regions". Avoiding this type of complexity is why I didn't code this to my own static structure to begin with!! AND PLUS...every other caching API has a Flush() command!!!!!
Memcached = flush_all
NCache = Clear()
SharedCache = Clear()
need I go on...?? ADD IT MICROSOFT!!! and get these engineers to stop creating useless solutions...please!
-
jeudi 23 février 2012 05:17Jeff, apologies for the inconvenience caused. There is no method right now in cache for Clear() but we will add it in future.
-
lundi 12 mars 2012 17:20
When? I have this exact problem. I've changed some of the objects being serialized and now all I get are exceptions, exceptions and exceptions. There's no purpose in having a cache that you can't get rid of, eventually.
-
lundi 12 mars 2012 20:21
This is a highly requested feature for many of us. Hopefully when the next changes are coming, it'll be implemented.
For now it's keeping a list of all items you've stored and retrieved from the cache the clear it and make sure to play well with the timeout based invalidation policy.
Be nice to nerds ... Chances are you'll end up working for one!
-
jeudi 10 mai 2012 17:15
this is ridiculous that you can't actively clear appfabric cache. we need, in fact MUST be able to clear cache on demand throughout the day and night. for example, if we're caching data that comes from what we call 'content blocks' which is managed by another department. when these bits of html are updated, we need to be able to invalidate the old one and update it with the new bit of data.
i'm extremely surprised to hear there's no method for this.
-
jeudi 10 mai 2012 17:24
Of course it's ridiculous. I dropped the whole thing and went to a memcached implementation. Works like a charm. Has a flush.
-
jeudi 10 mai 2012 19:38
here's something i just wrote that seems it might work. it iterates the default cache and resets all keys' time to expire and sets it to 01 millisecond (basically immediately).
public static void Flush()
{
var cache = GetCache();
foreach (var obj in cache.GetSystemRegions().SelectMany(cache.GetObjectsInRegion))
{
cache.ResetObjectTimeout(obj.Key, new TimeSpan(0,0,0,0,01)); //set to expire basically immediately
}
} -
mardi 20 novembre 2012 23:03
This doesn't work in Azure. Regions aren't supported.
When will this function get added? I'm getting charged for abandoned items in the cache because I can't clear them and I don't have the keys.

