* up going to the HashBagOStuff used for the in-memory cache).
*
* @ingroup Cache
+ * @TODO: Make this class use composition instead of calling super
*/
class CachedBagOStuff extends HashBagOStuff {
/** @var BagOStuff */
$this->attrMap = $backend->attrMap;
}
- protected function doGet( $key, $flags = 0 ) {
- $ret = parent::doGet( $key, $flags );
+ public function get( $key, $flags = 0 ) {
+ $ret = parent::get( $key, $flags );
if ( $ret === false && !$this->hasKey( $key ) ) {
- $ret = $this->backend->doGet( $key, $flags );
+ $ret = $this->backend->get( $key, $flags );
$this->set( $key, $ret, 0, self::WRITE_CACHE_ONLY );
}
return $ret;
// These just call the backend (tested elsewhere)
// @codeCoverageIgnoreStart
+ public function add( $key, $value, $exptime = 0, $flags = 0 ) {
+ if ( $this->get( $key ) === false ) {
+ return $this->set( $key, $value, $exptime, $flags );
+ }
+
+ return false; // key already set
+ }
+
+ public function incr( $key, $value = 1 ) {
+ $n = $this->backend->incr( $key, $value );
+ parent::delete( $key );
+
+ return $n;
+ }
+
public function lock( $key, $timeout = 6, $expiry = 6, $rclass = '' ) {
return $this->backend->lock( $key, $timeout, $expiry, $rclass );
}