Skip to content

Commit e806383

Browse files
committed
Added Memcached::OPT_PREFIX_KEY option support (fixed #744)
1 parent 06dc843 commit e806383

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

lib/Phpfastcache/Drivers/Memcached/Config.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ class Config extends ConfigurationOption
5757
*/
5858
protected $saslPassword = '';
5959

60+
/**
61+
* @var string
62+
*/
63+
protected $optPrefix = '';
64+
6065
/**
6166
* @return string
6267
*/
@@ -161,4 +166,24 @@ public function setPort(int $port): self
161166
$this->port = $port;
162167
return $this;
163168
}
169+
170+
/**
171+
* @return string
172+
* @since 8.0.2
173+
*/
174+
public function getOptPrefix(): string
175+
{
176+
return $this->optPrefix;
177+
}
178+
179+
/**
180+
* @param string $optPrefix
181+
* @return Config
182+
* @since 8.0.2
183+
*/
184+
public function setOptPrefix(string $optPrefix): Config
185+
{
186+
$this->optPrefix = trim($optPrefix);
187+
return $this;
188+
}
164189
}

lib/Phpfastcache/Drivers/Memcached/Driver.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ public function getStats(): DriverStatistic
8787
protected function driverConnect(): bool
8888
{
8989
$this->instance = new MemcachedSoftware();
90+
$optPrefix = $this->getConfig()->getOptPrefix();
9091
$this->instance->setOption(MemcachedSoftware::OPT_BINARY_PROTOCOL, true);
92+
93+
if ($optPrefix) {
94+
$this->instance->setOption(MemcachedSoftware::OPT_PREFIX_KEY, $optPrefix);
95+
}
96+
9197
$servers = $this->getConfig()->getServers();
9298

9399
if (count($servers) < 1) {

0 commit comments

Comments
 (0)