in reply to Re^5: PerlMonks Caching (still racy)
in thread PerlMonks Caching
Of course it is about things being displayed badly. You don't use memcached for storing the real data, just caching it (it doesn't try to be reliable enough to be a primary source).
I don't like updates to a shared cache to be primarily done when reading. When a cache entry expires, every read attempt is going to do extra work to construct a new cache entry until one of them finally gets the update pushed to the cache. Since the cache is fast, it is easy to get a bunch of requests noticing that the cache entry doesn't exist and then they all start the slower work of building the entry for the cache before the first can finish this slow step. That can certainly make your approach less efficient.
I much prefer readers to get the slightly old version of things until the update has completed and been pushed to the cache. It is silly to cause extra read activity to a subset of data exactly at the time you are trying to make updates to that subset of data. That just exacerbates concurrency problems in the DB.
Under your scheme, it would actually make more sense to not delete from the cache until after the updates to the DB have been completed.
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: PerlMonks Caching (push)
by tinita (Parson) on Apr 21, 2010 at 22:14 UTC | |
by tye (Sage) on Apr 22, 2010 at 04:17 UTC | |
by tinita (Parson) on Apr 22, 2010 at 08:54 UTC |