Vote count:
0
I'd like to use the cas MemcacheD functionality in php. The examples I've seen so far are something like this... (not including while loop around cas operation)
$cas_token = 'whatever';
$newValue = 'newValue';
$value = Memcached::get($key, $cas_token);
Memcached::cas($cas_token, $key, $newValue);
I don't want to get the actual value but I do want to 'register' my cas token. The reason I don't want the value is because it's huge and I don't need it. I append to the key's value. I do not set it. For example (in pseudo-pseudo-code)
if (!Memcached::append($key, $value) || Memcached::RES_NOTSTORED) {
Memcached::set($key, $value);
}
The actual problem I'm seeing is the following scenario with user a and user b 1) user a checked to see if the append will work -- it doesn't meaning that the key is not yet set 2) user b checks to see if the append will work -- it doesn't meaning that the key is not yet set 3) user a sets the key with an initial value 4) user b overwrites user a's set call and sets the key's value to their value, erasing what user a just did
The way I thought I could avoid this issue is by using cas (with append instead of get though) but it doesn't look like I'm able to do that unless I use a memcached::get call and that's real bad for my scenario. Like I said, the value is really big and this function get's called all the time.
I'm not opposed to going outside the box here if the Memcached library can't help me (making a lower level request directly to memcached) but I just wanted to see if a) I'm not understanding something and I can do what I want to do.... or b) There was a solution for my problem.
Aucun commentaire:
Enregistrer un commentaire