Search code examples
cachingmemcachedspymemcached

how to swap between two cache keys with CAS with memcached / spymemcached


I have a cache object (large json object) associated with a key. I would like to switch between this cache object / key instance and another without any down time in availability in one of the two.

I have been reading about memcached / spymemcached's CAS (compare and set) I feel as if this will allow me to swap between the two cache instance key pairs without any down time.

If so how can I implement the compare and set? Is there a code example using the spymemcached api to accomplish this?


Solution

  • I created the value I want stored temporarily. When it is finished populating, I delete the old cache and swap.