43 $params[
'keyspace'] = $backend->keyspace;
44 parent::__construct( $params );
46 $this->store = $backend;
49 $this->attrMap = $backend->attrMap;
53 public function get( $key, $flags = 0 ) {
54 $value = $this->procCache->
get( $key, $flags );
55 if ( $value !==
false || $this->procCache->hasKey( $key ) ) {
60 $value = $this->store->proxyCall(
74 public function getMulti( array $keys, $flags = 0 ) {
76 $valueByKeyCached = [];
79 foreach ( $keys as $key ) {
80 $value = $this->procCache->get( $key, $flags );
81 if ( $value ===
false && !$this->procCache->hasKey( $key ) ) {
84 $valueByKeyCached[$key] = $value;
88 $valueByKeyFetched = $this->store->proxyCall(
92 [ $keysFetch, $flags ],
95 $this->
setMulti( $valueByKeyFetched, self::TTL_INDEFINITE, self::WRITE_CACHE_ONLY );
97 return $valueByKeyCached + $valueByKeyFetched;
101 public function set( $key, $value, $exptime = 0, $flags = 0 ) {
102 $this->procCache->set( $key, $value, $exptime, $flags );
104 if ( $this->
fieldHasFlags( $flags, self::WRITE_CACHE_ONLY ) ) {
108 return $this->store->proxyCall(
118 public function delete( $key, $flags = 0 ) {
119 $this->procCache->delete( $key, $flags );
121 if ( $this->
fieldHasFlags( $flags, self::WRITE_CACHE_ONLY ) ) {
125 return $this->store->proxyCall(
135 public function add( $key, $value, $exptime = 0, $flags = 0 ) {
136 if ( $this->
get( $key ) ===
false ) {
137 return $this->
set( $key, $value, $exptime, $flags );
148 public function merge( $key, callable $callback, $exptime = 0, $attempts = 10, $flags = 0 ) {
149 $this->procCache->delete( $key );
151 return $this->store->proxyCall(
161 public function changeTTL( $key, $exptime = 0, $flags = 0 ) {
162 $this->procCache->delete( $key );
164 return $this->store->proxyCall(
174 public function lock( $key, $timeout = 6, $exptime = 6, $rclass =
'' ) {
175 return $this->store->proxyCall(
186 return $this->store->proxyCall(
198 ?callable $progress =
null,
202 $this->procCache->deleteObjectsExpiringBefore( $timestamp, $progress, $limit, $tag );
204 return $this->store->proxyCall(
214 public function setMulti( array $valueByKey, $exptime = 0, $flags = 0 ) {
215 $this->procCache->setMulti( $valueByKey, $exptime, $flags );
217 if ( $this->
fieldHasFlags( $flags, self::WRITE_CACHE_ONLY ) ) {
221 return $this->store->proxyCall(
232 $this->procCache->deleteMulti( $keys, $flags );
234 if ( $this->
fieldHasFlags( $flags, self::WRITE_CACHE_ONLY ) ) {
238 return $this->store->proxyCall(
249 $this->procCache->changeTTLMulti( $keys, $exptime, $flags );
251 if ( $this->
fieldHasFlags( $flags, self::WRITE_CACHE_ONLY ) ) {
255 return $this->store->proxyCall(
265 public function incrWithInit( $key, $exptime, $step = 1, $init =
null, $flags = 0 ) {
266 $this->procCache->delete( $key );
268 return $this->store->proxyCall(
279 parent::setMockTime( $time );
280 $this->procCache->setMockTime( $time );
281 $this->store->setMockTime( $time );
292 throw new LogicException( __METHOD__ .
' must be called immediately after get()' );
307class_alias( CachedBagOStuff::class,
'CachedBagOStuff' );
if(!defined('MW_SETUP_CALLBACK'))