*
* @ingroup Cache
*/
-class WinCacheBagOStuff extends BagOStuff {
+class WinCacheBagOStuff extends MediumSpecificBagOStuff {
protected function doGet( $key, $flags = 0, &$casToken = null ) {
$casToken = null;
$blob = wincache_ucache_get( $key );
- if ( !is_string( $blob ) ) {
+ if ( !is_string( $blob ) && !is_int( $blob ) ) {
return false;
}
- $value = unserialize( $blob );
+ $value = $this->unserialize( $blob );
if ( $value !== false ) {
$casToken = (string)$blob; // don't bother hashing this
}
return $success;
}
- public function set( $key, $value, $expire = 0, $flags = 0 ) {
- $result = wincache_ucache_set( $key, serialize( $value ), $expire );
+ protected function doSet( $key, $value, $exptime = 0, $flags = 0 ) {
+ $result = wincache_ucache_set( $key, $this->serialize( $value ), $exptime );
// false positive, wincache_ucache_set returns an empty array
// in some circumstances.
}
public function add( $key, $value, $exptime = 0, $flags = 0 ) {
- $result = wincache_ucache_add( $key, serialize( $value ), $exptime );
+ if ( wincache_ucache_exists( $key ) ) {
+ return false; // avoid warnings
+ }
+
+ $result = wincache_ucache_add( $key, $this->serialize( $value ), $exptime );
// false positive, wincache_ucache_add returns an empty array
// in some circumstances.
return ( $result === [] || $result === true );
}
- public function delete( $key, $flags = 0 ) {
+ protected function doDelete( $key, $flags = 0 ) {
wincache_ucache_delete( $key );
return true;