Noob question about how to avoid overwriting cache values
André Cruz
andre.cruz at segula.pt
Thu Jul 5 08:22:44 UTC 2007
If incr and decr are not enough for you you could try using "add" to
create locks.
while (! add("LOCK", TIMEOUT)) {
sleep();
}
# got lock, fetch and update value
delete("LOCK");
On 2007/07/05, at 09:12, Lei Jin wrote:
> Hello, Memcached experts:
>
> I have a question about how to maintain data
> integrity if two machines both write to a data field
> stored in memcache. Basically, I have a value that
> records user activity scores. Periodically, machine A
> and machine B will update that value based on the
> previous value and the activity of the user on the
> respective machine during this period. If machine A
> and B do this in order, then everything is fine. But
> the problem happens if A and B do it at about the same
> time, so both are working off of the original value.
> In that case, one machine will override the change
> made by the other machine. In DB transactions, this
> obviously is not a problem, but my question is, how do
> I prevent this from happening when I'm dealing with a
> cache? Thanks in advance.
>
>
>
> ______________________________________________________________________
> ______________
> Take the Internet to Go: Yahoo!Go puts the Internet in your pocket:
> mail, news, photos & more.
> http://mobile.yahoo.com/go?refer=1GNXIC
More information about the memcached
mailing list