Flush cache from code?
There is a mechanism in the server console to flush the entire cache for a Memcached tier, and I would like to know if there is a way to do the same thing from the client (in .NET)? The reason I ask is because when we do site upgrades many times we need to toss the cache away and start over to ensure the caches will be invalid, especially if we are changing the format of stuff stored in the cache. So I can do it from the server console, but I really need a way to trigger this from our site upgrade code, but I don't recall seeing such a function in the client API?
Ok thanks. I did not find it in the Couchbase docs, and what bothers me is this page:
http://www.couchbase.com/docs/couchbase-manual-1.8//restapi-flushing-buc...
Specifically this note:
"As of Couchbase 1.6 bucket flushing via REST API is not supported. Flushing via Couchbase SDKs as of Couchbase Server 1.8.1 is disabled by default."
Does that mean that the code Enyim uses for FlushAll won't actually work with 1.8.1?
This documentation is specific to the Couchbase bucket, not the memcached bucket. As far as I know there shouldn't be any reason why you shouldn't use it with a memcached bucket.
The reason that we don't support it and have turned it off by default in 1.8.1 is that we have seen it cause strange issues due to the fact that the command is asynchronous but schedules deletion of the entire database on disk. This deletion can take a while depending on the number of items and since the command is asynchronous you can start adding more items while this deletion is happening. This scenario can cause strange behavior and as a result has been deemed unsafe for Couchbase buckets. The memcached bucket however doesn't have any persistence so there shouldn't be any issues for that bucket type.
On another note our new recommendation to users of Couchbase buckets is to just delete and recreate a bucket if you want to do a "flush all".
Ok great, that makes a lot of sense. I only need to flush our cache tier not Couchbase buckets. Thanks!
The CouchbaseClient class in the .Net client extends the MemcachedClient class with can be found in the Enyim memcached client. The Enyim client is a dependency of the Couchbase .NET Client. Anyways, there is a FlushAll() method in the MemcachedClient class that you can use. See my link for the source code.
https://github.com/enyim/EnyimMemcached/blob/master/Enyim.Caching/Memcac...