Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | SDKs | SDKs

Flush cache from code?

4 replies [Last post]
  • Login or register to post comments
Fri, 07/06/2012 - 16:23
kendallb
Offline
Joined: 02/27/2012
Groups: None

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?

Top
  • Login or register to post comments
Sat, 07/07/2012 - 19:11
mikew
Offline
Joined: 03/14/2011
Groups:

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...

Top
  • Login or register to post comments
Sat, 07/07/2012 - 22:39
kendallb
Offline
Joined: 02/27/2012
Groups: None

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?

Top
  • Login or register to post comments
Sat, 07/07/2012 - 23:58
mikew
Offline
Joined: 03/14/2011
Groups:

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".

Top
  • Login or register to post comments
Sun, 07/08/2012 - 08:58
kendallb
Offline
Joined: 02/27/2012
Groups: None

Ok great, that makes a lot of sense. I only need to flush our cache tier not Couchbase buckets. Thanks!

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker