29 public function __construct($namespace =
'default', \
Stash\Pool $pool = null, $ttl = null) {
30 parent::__construct();
37 throw new \ConfigurationException(
'No memcache servers defined, please populate the $this->CONFIG->memcache_servers variable');
40 $this->stash_pool = $pool;
50 _elgg_services()->events->registerHandler(
'cache:flush',
'system', array($this,
'clear'));
72 private function makeMemcacheKey(
$key) {
75 return "/{$this->getNamespace()}/$key";
97 $item->expiresAfter($ttl);
118 public function load(
$key, $unused1 = 0, $unused2 = null) {
119 $key = $this->makeMemcacheKey(
$key);
121 $item = $this->stash_pool->getItem(
$key);
123 $item->setInvalidationMethod(\
Stash\Invalidation::NONE);
126 if (
$item->isMiss()) {
144 $key = $this->makeMemcacheKey(
$key);
145 return $this->stash_pool->getItem(
$key)->clear();
156 return $this->stash_pool->getItem(
"/{$this->getNamespace()}")->clear();
169 $config_prefix =
_elgg_services()->config->getVolatile(
'memcache_namespace_prefix');
170 if ($config_prefix) {
171 $namespace = $config_prefix . $namespace;
174 parent::setNamespace($namespace);
clear()
Clears all values in the namespace of this cache.
load($key, $unused1=0, $unused2=null)
Retrieves data.
save($key, $data, $ttl=null)
Saves a name and value to the cache.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
setNamespace($namespace="default")
Set the namespace of this cache.
setDefaultExpiry($ttl=0)
Set the default TTL.
__construct($namespace= 'default',\Stash\Pool $pool=null, $ttl=null)
Constructor.