19 declare(strict_types=1);
36 if (!class_exists(\Memcached::class)) {
48 return class_exists(\Memcached::class) && $this->server !== null && $this->server->getVersion() !==
false;
53 return $this->server->get($this->
buildKey($container, $key)) !==
false;
58 return $this->server->get($this->
buildKey($container,
$key)) ?: null;
61 public function set(
string $container,
string $key,
string $value,
int $ttl):
void 63 $this->server->set($this->
buildKey($container, $key), $value, $ttl);
68 $this->server->delete($this->
buildKey($container, $key), 0);
74 foreach ($this->server->getAllKeys() as
$key) {
75 if (str_starts_with($key, $prefix)) {
76 $this->server->set($key,
false, 0);
79 foreach ($this->server->getAllKeys() as
$key) {
80 if (str_starts_with($key, $prefix)) {
86 $this->server->flushBuffers();
92 $this->server->flush();
97 $this->server = new \Memcached(self::PERSISTENT_ID);
99 foreach ($nodes as $node) {
100 $this->server->addServer(
103 $node->getWeight() ?? 100 / count($nodes)
buildKey(string $container, string $key)
buildContainerPrefix(string $container)
__construct(Config $config)
has(string $container, string $key)
flushContainer(string $container)
initServer(Config $config)