How to maintain cache update on different memcached servers?
Ivan Krstić
krstic at solarsail.hcs.harvard.edu
Tue Oct 31 15:57:34 UTC 2006
howard chen wrote:
> Support a user query a object thru complex SQL join statement from
> MySQL slave B, this object is cached using Memcached B, in order to
> offload the MySQL slave B
memcached doesn't do machine-locality. It buckets based on a simple
checksum across all machines in the pool. Therefore, if you cache the
complex query, it'll wind up on either server A or B, and that's (for
all practical purposes) outside of your control. You have two options at
this point: your database access layer can either invalidate the cache
for the complex query every time it writes to a row that _could_ affect
the complex query result, OR you can decide that the complex query is so
expensive that you're willing to have it report stale information for a
short period of time, e.g. 30 seconds or 5 minutes or an hour. In the
latter case, you'd give the timeout when putting the query into the cache.
--
Ivan Krstić <krstic at solarsail.hcs.harvard.edu> | GPG: 0x147C722D
More information about the memcached
mailing list