public function cas($token, $key, $value, $expire = 0)
{
$originalValue = isset($this->tokens[$token]) ? $this->tokens[$token] : null;
// value is no longer the same as what we used for token
if (serialize($this->get($key)) !== $originalValue) {
return false;
}
// "CAS" value to local cache/memory
$success = $this->local->set($key, $value, $expire);
if ($success === false) {
return false;
}
// only schedule the CAS to be performed on real cache if it was OK on
// local cache
$this->defer->cas($originalValue, $key, $value, $expire);
return true;
}