52 $params[
'keyspace'] = $backend->keyspace;
55 $this->store = $backend;
58 $this->attrMap = $backend->attrMap;
61 public function get( $key, $flags = 0 ) {
62 $value = $this->procCache->
get( $key, $flags );
63 if ( $value !==
false || $this->procCache->hasKey( $key ) ) {
67 $value = $this->store->proxyCall(
79 public function getMulti( array $keys, $flags = 0 ) {
80 $valueByKeyCached = [];
83 foreach ( $keys as $key ) {
84 $value = $this->procCache->get( $key, $flags );
85 if ( $value ===
false && !$this->procCache->hasKey( $key ) ) {
88 $valueByKeyCached[$key] = $value;
92 $valueByKeyFetched = $this->store->proxyCall(
96 [ $keysFetch, $flags ],
99 $this->
setMulti( $valueByKeyFetched, self::TTL_INDEFINITE, self::WRITE_CACHE_ONLY );
101 return $valueByKeyCached + $valueByKeyFetched;
104 public function set( $key, $value, $exptime = 0, $flags = 0 ) {
105 $this->procCache->set( $key, $value, $exptime, $flags );
107 if ( $this->
fieldHasFlags( $flags, self::WRITE_CACHE_ONLY ) ) {
111 return $this->store->proxyCall(
120 public function delete( $key, $flags = 0 ) {
121 $this->procCache->delete( $key, $flags );
123 if ( $this->
fieldHasFlags( $flags, self::WRITE_CACHE_ONLY ) ) {
127 return $this->store->proxyCall(
136 public function add( $key, $value, $exptime = 0, $flags = 0 ) {
137 if ( $this->
get( $key ) ===
false ) {
138 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(
160 public function changeTTL( $key, $exptime = 0, $flags = 0 ) {
161 $this->procCache->delete( $key );
163 return $this->store->proxyCall(
172 public function lock( $key, $timeout = 6, $exptime = 6, $rclass =
'' ) {
173 return $this->store->proxyCall(
183 return $this->store->proxyCall(
194 callable $progress =
null,
198 $this->procCache->deleteObjectsExpiringBefore( $timestamp, $progress, $limit, $tag );
200 return $this->store->proxyCall(
209 public function setMulti( array $valueByKey, $exptime = 0, $flags = 0 ) {
210 $this->procCache->setMulti( $valueByKey, $exptime, $flags );
212 if ( $this->
fieldHasFlags( $flags, self::WRITE_CACHE_ONLY ) ) {
216 return $this->store->proxyCall(
226 $this->procCache->deleteMulti( $keys, $flags );
228 if ( $this->
fieldHasFlags( $flags, self::WRITE_CACHE_ONLY ) ) {
232 return $this->store->proxyCall(
242 $this->procCache->changeTTLMulti( $keys, $exptime, $flags );
244 if ( $this->
fieldHasFlags( $flags, self::WRITE_CACHE_ONLY ) ) {
248 return $this->store->proxyCall(
257 public function incrWithInit( $key, $exptime, $step = 1, $init =
null, $flags = 0 ) {
258 $this->procCache->delete( $key );
260 return $this->store->proxyCall(
270 parent::setMockTime( $time );
271 $this->procCache->setMockTime( $time );
272 $this->store->setMockTime( $time );
279class_alias( CachedBagOStuff::class,
'CachedBagOStuff' );
array $params
The job parameters.