**/
const KEY_SUFFIX = ':1';
- public function get( $key, &$casToken = null, $flags = 0 ) {
+ protected function doGet( $key, $flags = 0 ) {
$val = apc_fetch( $key . self::KEY_SUFFIX );
- $casToken = $val;
-
return $val;
}
* higher tiers using standard TTLs.
*
* @param string $key
- * @param mixed $casToken [optional]
* @param integer $flags Bitfield of BagOStuff::READ_* constants [optional]
+ * @param integer $oldFlags [unused]
* @return mixed Returns false on failure and if the item does not exist
*/
- abstract public function get( $key, &$casToken = null, $flags = 0 );
+ public function get( $key, $flags = 0, $oldFlags = null ) {
+ // B/C for ( $key, &$casToken = null, $flags = 0 )
+ $flags = is_int( $oldFlags ) ? $oldFlags : $flags;
+
+ return $this->doGet( $key, $flags );
+ }
+
+ /**
+ * @param string $key
+ * @param integer $flags Bitfield of BagOStuff::READ_* constants [optional]
+ * @return mixed Returns false on failure and if the item does not exist
+ */
+ abstract protected function doGet( $key, $flags = 0 );
+
+ /**
+ * @note: This method is only needed if cas() is not is used for merge()
+ *
+ * @param string $key
+ * @param mixed $casToken
+ * @param integer $flags Bitfield of BagOStuff::READ_* constants [optional]
+ * @return mixed Returns false on failure and if the item does not exist
+ */
+ protected function getWithToken( $key, &$casToken, $flags = 0 ) {
+ throw new Exception( __METHOD__ . ' not implemented.' );
+ }
/**
* Set an item
do {
$this->clearLastError();
$casToken = null; // passed by reference
- $currentValue = $this->get( $key, $casToken );
+ $currentValue = $this->getWithToken( $key, $casToken, BagOStuff::READ_LATEST );
if ( $this->getLastError() ) {
return false; // don't spam retries (retry only on races)
}
}
$this->clearLastError();
- $currentValue = $this->get( $key );
+ $currentValue = $this->get( $key, BagOStuff::READ_LATEST );
if ( $this->getLastError() ) {
$success = false;
} else {
* @ingroup Cache
*/
class EmptyBagOStuff extends BagOStuff {
- public function get( $key, &$casToken = null, $flags = 0 ) {
+ protected function doGet( $key, $flags = 0 ) {
return false;
}
return true;
}
- public function get( $key, &$casToken = null, $flags = 0 ) {
+ protected function doGet( $key, $flags = 0 ) {
if ( !isset( $this->bag[$key] ) ) {
return false;
}
return false;
}
- $casToken = $this->bag[$key][0];
-
return $this->bag[$key][0];
}
$this->readStore->setDebug( $debug );
}
- public function get( $key, &$casToken = null, $flags = 0 ) {
+ protected function doGet( $key, $flags = 0 ) {
return ( $flags & self::READ_LATEST )
- ? $this->writeStore->get( $key, $casToken, $flags )
- : $this->readStore->get( $key, $casToken, $flags );
+ ? $this->writeStore->get( $key, $flags )
+ : $this->readStore->get( $key, $flags );
}
public function getMulti( array $keys, $flags = 0 ) {
* @ingroup Cache
*/
class WinCacheBagOStuff extends BagOStuff {
- public function get( $key, &$casToken = null, $flags = 0 ) {
+ 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;
* @ingroup Cache
*/
class XCacheBagOStuff extends BagOStuff {
- public function get( $key, &$casToken = null, $flags = 0 ) {
+ protected function doGet( $key, $flags = 0 ) {
$val = xcache_get( $key );
if ( is_string( $val ) ) {
return $params;
}
- public function get( $key, &$casToken = null, $flags = 0 ) {
+ protected function doGet( $key, $flags = 0 ) {
+ $casToken = null;
+
+ return $this->getWithToken( $key, $casToken, $flags );
+ }
+
+ protected function getWithToken( $key, &$casToken, $flags = 0 ) {
return $this->client->get( $this->encodeKey( $key ), $casToken );
}
$this->client->addServers( $servers );
}
- public function get( $key, &$casToken = null, $flags = 0 ) {
+ protected function getWithToken( $key, &$casToken, $flags = 0 ) {
$this->debugLog( "get($key)" );
$result = $this->client->get( $this->encodeKey( $key ), null, $casToken );
$result = $this->checkResult( $key, $result );
$this->doWrite( self::ALL, 'setDebug', $debug );
}
- public function get( $key, &$casToken = null, $flags = 0 ) {
+ protected function doGet( $key, $flags = 0 ) {
$misses = 0; // number backends checked
$value = false;
foreach ( $this->caches as $cache ) {
- $value = $cache->get( $key, $casToken, $flags );
+ $value = $cache->get( $key, $flags );
if ( $value !== false ) {
break;
}
}
}
- public function get( $key, &$casToken = null, $flags = 0 ) {
+ protected function doGet( $key, $flags = 0 ) {
list( $server, $conn ) = $this->getConnection( $key );
if ( !$conn ) {
return false;
}
try {
$value = $conn->get( $key );
- $casToken = $value;
$result = $this->unserialize( $value );
} catch ( RedisException $e ) {
$result = false;
}
}
- public function get( $key, &$casToken = null, $flags = 0 ) {
+ protected function doGet( $key, $flags = 0 ) {
+ $casToken = null;
+
+ return $this->getWithToken( $key, $casToken, $flags );
+ }
+
+ protected function getWithToken( $key, &$casToken, $flags = 0 ) {
$values = $this->getMulti( array( $key ) );
if ( array_key_exists( $key, $values ) ) {
$casToken = $values[$key];