Из доки на мемкеш-клиент:
# Do atomic test-and-set operations. my $cas_val = $memd->gets('nkey'); $$cas_val[1] = 0 if $$cas_val[1] == 12; if ($memd->cas('nkey', @$cas_val)) { print "OK, value updated\n"; } else { print "Update failed, probably another client" . " has updated the value\n"; }