48 $params[
'keyspace'] = $backend->keyspace;
51 $this->store = $backend;
54 $this->attrMap = $backend->attrMap;
57 public function get( $key, $flags = 0 ) {
58 $value = $this->procCache->
get( $key, $flags );
59 if ( $value !==
false || $this->procCache->hasKey( $key ) ) {
63 $value = $this->store->proxyCall(
75 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;
100 public function set( $key, $value, $exptime = 0, $flags = 0 ) {
101 $this->procCache->set( $key, $value, $exptime, $flags );
103 if ( $this->
fieldHasFlags( $flags, self::WRITE_CACHE_ONLY ) ) {
107 return $this->store->proxyCall(
116 public function delete( $key, $flags = 0 ) {
117 $this->procCache->delete( $key, $flags );
119 if ( $this->
fieldHasFlags( $flags, self::WRITE_CACHE_ONLY ) ) {
123 return $this->store->proxyCall(
132 public function add( $key, $value, $exptime = 0, $flags = 0 ) {
133 if ( $this->
get( $key ) ===
false ) {
134 return $this->
set( $key, $value, $exptime, $flags );
144 public function merge( $key, callable $callback, $exptime = 0, $attempts = 10, $flags = 0 ) {
145 $this->procCache->delete( $key );
147 return $this->store->proxyCall(
156 public function changeTTL( $key, $exptime = 0, $flags = 0 ) {
157 $this->procCache->delete( $key );
159 return $this->store->proxyCall(
168 public function lock( $key, $timeout = 6, $exptime = 6, $rclass =
'' ) {
169 return $this->store->proxyCall(
179 return $this->store->proxyCall(
190 ?callable $progress =
null,
194 $this->procCache->deleteObjectsExpiringBefore( $timestamp, $progress, $limit, $tag );
196 return $this->store->proxyCall(
205 public function setMulti( array $valueByKey, $exptime = 0, $flags = 0 ) {
206 $this->procCache->setMulti( $valueByKey, $exptime, $flags );
208 if ( $this->
fieldHasFlags( $flags, self::WRITE_CACHE_ONLY ) ) {
212 return $this->store->proxyCall(
222 $this->procCache->deleteMulti( $keys, $flags );
224 if ( $this->
fieldHasFlags( $flags, self::WRITE_CACHE_ONLY ) ) {
228 return $this->store->proxyCall(
238 $this->procCache->changeTTLMulti( $keys, $exptime, $flags );
240 if ( $this->
fieldHasFlags( $flags, self::WRITE_CACHE_ONLY ) ) {
244 return $this->store->proxyCall(
253 public function incrWithInit( $key, $exptime, $step = 1, $init =
null, $flags = 0 ) {
254 $this->procCache->delete( $key );
256 return $this->store->proxyCall(
266 parent::setMockTime( $time );
267 $this->procCache->setMockTime( $time );
268 $this->store->setMockTime( $time );
275class_alias( CachedBagOStuff::class,
'CachedBagOStuff' );
array $params
The job parameters.