*/
class WinCacheBagOStuff extends BagOStuff {
protected function doGet( $key, $flags = 0 ) {
- $casToken = null;
-
- return $this->getWithToken( $key, $casToken, $flags );
- }
-
- protected function getWithToken( $key, &$casToken, $flags = 0 ) {
$val = wincache_ucache_get( $key );
-
- $casToken = $val;
-
if ( is_string( $val ) ) {
$val = unserialize( $val );
}
return ( is_array( $result ) && $result === [] ) || $result;
}
- protected function cas( $casToken, $key, $value, $exptime = 0 ) {
- return wincache_ucache_cas( $key, $casToken, serialize( $value ) );
- }
-
public function delete( $key ) {
wincache_ucache_delete( $key );
}
public function merge( $key, callable $callback, $exptime = 0, $attempts = 10, $flags = 0 ) {
- return $this->mergeViaCas( $key, $callback, $exptime, $attempts );
+ if ( wincache_lock( $key ) ) { // optimize with FIFO lock
+ $ok = $this->mergeViaLock( $key, $callback, $exptime, $attempts, $flags );
+ wincache_unlock( $key );
+ } else {
+ $ok = false;
+ }
+
+ return $ok;
}
}