Memcache update the difference
dormando at rydia.net
Thu Aug 30 08:35:49 UTC 2007
Khamis Siksek wrote:
> Dear all,
> Is there a way to update a value in memcached using the difference?
> For example if I cached an array (e.g. the result of a select query from
> a database) using the key 123:
> set ('123', $a); // $a an array containing 10 rows
> and after a while the table or fields got updated in the database, what
> I will need to do now is to do the same thing I did before which is set
> ('123', $a); // now $a contains more or less rows with some modified fields
> This means I have an overhead (the rows or fields that didn't change)
> that I need to cache again, so is there a way that makes me set only the
> difference (same as patching a source file using diff -u result).
It's probably not that huge of an overhead to reset an array of 10
items. If you're worried, split it out into more keys.
I can vaguely recall binary patching being discussed here and there. The
consensus here is that it gets complicated. The client would need to
know the binary offsets to work with, which is not likely to be the
common case at all. Easier to just work with it.
More information about the memcached