10000 [Cache] Make RetryProxyAdapter TagAwaare · symfony/symfony@face50d · GitHub
[go: up one dir, main page]

Skip to content

Commit face50d

Browse files
committed
[Cache] Make RetryProxyAdapter TagAwaare
1 parent 8748820 commit face50d

File tree

2 files changed

+18
-4
lines changed

2 file 10000 s changed

+18
-4
lines changed

src/Symfony/Component/Cache/Adapter/RedisEphemeralTagAwareAdapter.php

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
* It's not the case when all reads and writes go to a master node(s). Adapter doesn't change the source for reads,
3333
* it's your responsibility to configure redis client according to your needs.
3434
*
35+
* Hint: RetryProxyAdapter::class can help to mitigate mentioned replication lag issues as well as cache stampedes.
36+
*
3537
* @requires Redis 2.6.12+
3638
*
3739
* @author Sergey Belyshkin <sbelyshkin@gmail.com>

src/Symfony/Component/Cache/Adapter/RetryProxyAdapter.php

+16-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
* @author Sergey Belyshkin <sbelyshkin@gmail.com>
3939
*/
40-
class RetryProxyAdapter implements AdapterInterface, CacheInterface, LoggerAwareInterface, PruneableInterface, ResettableInterface
40+
class RetryProxyAdapter implements TagAwareAdapterInterface, CacheInterface, LoggerAwareInterface, PruneableInterface, ResettableInterface
4141
{
4242
use ContractsTrait;
4343
use LoggerAwareTrait;
@@ -136,6 +136,18 @@ public function __construct(CacheItemPoolInterface $pool, int $timeout = 10000,
136136
}
137137
}
138138

139+
/**
140+
* {@inheritdoc}
141+
*/
142+
public function invalidateTags(array $tags)
143+
{
144+
if ($this->pool instanceof TagAwareAdapterInterface) {
145+
return $this->pool->invalidateTags($tags);
146+
}
147+
148+
return false;
149+
}
150+
139151
/**
140152
* {@inheritdoc}
141153
*/
@@ -151,7 +163,7 @@ public function clear(string $prefix = '')
151163
/**
152164
* {@inheritdoc}
153165
*/
154-
public function commit()
166+
public function commit(): bool
155167
{
156168
return $this->pool->commit();
157169
}
@@ -175,15 +187,15 @@ public function deleteItems(array $keys): bool
175187
/**
176188
* {@inheritdoc}
177189
*/
178-
public function hasItem($key)
190+
public function hasItem($key): bool
179191
{
180192
return $this->pool->hasItem($key);
181193
}
182194

183195
/**
184196
* {@inheritdoc}
185197
*/
186-
public function save(CacheItemInterface $item)
198+
public function save(CacheItemInterface $item): bool
187199
{
188200
return $this->pool->save($item);
189201
}

0 commit comments

Comments
 (0)
0