61 parent::__construct();
80 if ($this->disabled) {
89 if (is_int($expire_after)) {
90 $item->expiresAfter($expire_after);
92 $item->expiresAt($expire_after);
95 return $this->pool->save(
$item);
106 if ($this->disabled) {
112 if (!
$item->isHit()) {
116 if ($this->validate_lastcache && $this->config->lastcache) {
119 if (
$item->getCreationDate()->getTimestamp() < $expiration_date->getTimestamp()) {
126 }
catch (PhpfastcacheRootException $e) {
128 elgg_log($e->getMessage(),
'ERROR');
137 if ($this->disabled) {
148 return $this->pool->clear();
200 return "{$this->getNamespace()}_{$id}";
215 if (!is_string(
$key) && !is_int(
$key)) {
219 return str_replace([
'{',
'}',
'(',
')',
'/',
'\\',
'@',
':'],
'_',
"{$key}");
236 $drivers = array_filter($drivers);
238 if (empty($drivers)) {
242 if (!empty($ephemeral)) {
243 $drivers[] = $ephemeral;
247 if (empty($drivers)) {
251 if (
count($drivers) === 1) {
252 return array_shift($drivers);
255 $cluster =
new ClusterAggregator($this->
getNamespace());
256 foreach ($drivers as $driver) {
257 $cluster->aggregateDriver($driver);
260 $cluster_driver = $cluster->getCluster();
261 $cluster_driver->setConfig(
new ConfigurationOption([
262 'useStaticItemCaching' =>
true,
263 'itemDetailedDate' =>
true,
266 return $cluster_driver;
278 if (!self::isRedisAvailable()) {
299 if (!self::isMemcacheAvailable()) {
327 }
catch (\Phpfastcache\Exceptions\PhpfastcacheIOException $e) {
328 if (!$this->config->installer_running) {
352 }
catch (\Phpfastcache\Exceptions\PhpfastcacheIOException $e) {
353 if (!$this->config->installer_running) {
370 $config = new \Phpfastcache\Drivers\Memory\Config();
372 $config->setUseStaticItemCaching(
true);
373 $config->setItemDetailedDate(
true);
387 $config = new \Phpfastcache\Drivers\Devnull\Config();
400 return class_exists(
'Memcached');
411 return extension_loaded(
'Redis');
static isMemcacheAvailable()
Helper function to check if memcache is available.
$ttl
TTL of saved items (default timeout after a day to prevent anything getting too stale) ...
A generic parent class for Configuration exceptions.
Exception thrown if an argument is not of the expected type.
static fromElggConfig(string $namespace,\Elgg\Config $config)
Factory to return a config object to be used when starting a driver.
Saves user notification settings.
getNamespace()
Get the namespace currently defined.
load($key)
Load data from the cache using a given key.
const ELGG_CACHE_BLACK_HOLE
Cache init values.
prefixInstanceId(string $id)
Prefixes instance ids with namespace.
buildEphemeralDriver()
Builds in-memory driver.
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif($item instanceof\ElggRelationship) elseif(is_callable([$item, 'getType']))
setNamespace($namespace= 'default')
Set the namespace of this cache.
sanitizeItemKey($key)
Sanitizes item key for cache.
if(!$entity instanceof\ElggUser) $data
buildMemcachedDriver()
Builds Memcached driver.
save($key, $data, $expire_after=null)
Save data in a cache.
static fromElggConfig(string $namespace,\Elgg\Config $config)
Factory to return a config object to be used when starting a driver.
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
static fromElggConfig(string $namespace,\Elgg\Config $config)
Factory to return a config object to be used when starting a driver.
The Elgg cache base class.
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
const ELGG_CACHE_LOCALFILESYSTEM
Extension of the DateTime class to support formatting a date using the locale.
createPool()
Create a new cluster/pool of drivers.
const ELGG_CACHE_PERSISTENT
const ELGG_CACHE_FILESYSTEM
static isRedisAvailable()
Helper function to check if Redis is available.
buildRedisDriver()
Builds Redis driver.
static normalizeTime($time)
Returns DateTime object based on time representation.
buildLocalFileSystemDriver()
Builds local file system driver.
buildBlackHoleDriver()
Builds null cache driver.
$id
Generic annotation delete action.
buildFileSystemDriver()
Builds file system driver.
static fromElggConfig(string $namespace,\Elgg\Config $config)
Factory to return a config object to be used when starting a driver.
__construct($namespace, Config $config, $flags, bool $validate_lastcache=true)
Constructor.