On Nov 1, 9:53 am, jainy <[EMAIL PROTECTED]> wrote: > Hi > > I am evaluating memcached for my DB performance / scalability. For my > purposes Data Correctness is Key constraint. > > I have potential problem of Data getting stale ( cache inconsistency > coherency ) because I have multiple readers and writers on the same > data set. > > Q1: Is memcached only suitable for data where correctness MUST not be > important ?
I wouldn't think so, but it's not transactional, so it's really hard to get invalidation *exactly* right for highly concurrent applications. Do you have something specific in mind? > Q2 : Is it possible for me to reliably enforce cache consistency in > memcached ? Are there any lock / unlock apis available for C++ in > memcached framework ? No, memcached isn't a lock. There are a few different servers that provide such facilities if you need them (I wrote elock for simple locking, but there's also ZooKeeper if you need something more like chubby). > Q3 : What if my cache invalidation / removal fails ? Again I need > locks for that so that I restrict my readers ? I can't speak much to your application. I had a similar thing a few years ago wherein I just kept a lazily evaluated lock in the objects themselves such that the version number was validated upon save operations. Similarly, I've got a (soft) realtime search engine that keeps its index in memcached in such a way that the search matcher processes can keep an L2 cache of them in memory and only validate the version of the index on each request. Neither needs a lock, just a unique number (which memcached does provide).
