| 1 | <?php |
||
| 5 | class Mcrouter |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Prefix for shared cache (used in Mcrouter) |
||
| 9 | * |
||
| 10 | * @var string |
||
| 11 | */ |
||
| 12 | public const SHARED_PREFIX = '/default/shr/'; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Shared prefix for tags |
||
| 16 | * |
||
| 17 | * @var string |
||
| 18 | */ |
||
| 19 | private $sharedPrefix; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Supported prefixes in Mcrouter |
||
| 23 | * |
||
| 24 | * @var array<string> |
||
| 25 | */ |
||
| 26 | private $prefixes = []; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Mcrouter constructor |
||
| 30 | * |
||
| 31 | * @param string $sharedPrefix |
||
| 32 | * @param array<string> $supportedPrefixes |
||
| 33 | */ |
||
| 34 | 27 | public function __construct(string $sharedPrefix, array $supportedPrefixes = []) |
|
| 39 | |||
| 40 | /** |
||
| 41 | * Get the cache prefixes. |
||
| 42 | * |
||
| 43 | * @return array<string> |
||
| 44 | */ |
||
| 45 | 18 | public function getPrefixes(): array |
|
| 49 | |||
| 50 | /** |
||
| 51 | * Get the cache key with Mcrouter shared prefix. |
||
| 52 | * |
||
| 53 | * @param string $key |
||
| 54 | * |
||
| 55 | * @return string |
||
| 56 | */ |
||
| 57 | 10 | public function getSharedKey(string $key): string |
|
| 61 | } |
||
| 62 |