60 parent::__construct();
79 if ($this->disabled) {
88 if (is_int($expire_after)) {
89 $item->expiresAfter($expire_after);
91 $item->expiresAt($expire_after);
94 return $this->pool->save(
$item);
105 if ($this->disabled) {
110 if (!
$item->isHit()) {
114 if ($this->validate_lastcache && $this->config->lastcache) {
117 if (
$item->getCreationDate()->getTimestamp() < $expiration_date->getTimestamp()) {
130 if ($this->disabled) {
141 return $this->pool->clear();
193 return "{$this->getNamespace()}_{$id}";
208 if (!is_string(
$key) && !is_int(
$key)) {
212 return str_replace([
'{',
'}',
'(',
')',
'/',
'\\',
'@',
':'],
'_',
"{$key}");
229 $drivers = array_filter($drivers);
231 if (empty($drivers)) {
235 if (!empty($ephemeral)) {
236 $drivers[] = $ephemeral;
240 if (empty($drivers)) {
244 if (
count($drivers) === 1) {
245 return array_shift($drivers);
248 $cluster =
new ClusterAggregator($this->
getNamespace());
249 foreach ($drivers as $driver) {
250 $cluster->aggregateDriver($driver);
253 $cluster_driver = $cluster->getCluster();
254 $cluster_driver->setConfig(
new ConfigurationOption([
255 'preventCacheSlams' =>
true,
256 'useStaticItemCaching' =>
true,
257 'itemDetailedDate' =>
true,
260 return $cluster_driver;
272 if (!self::isRedisAvailable()) {
293 if (!self::isMemcacheAvailable()) {
321 }
catch (\Phpfastcache\Exceptions\PhpfastcacheIOException $e) {
322 if (!$this->config->installer_running) {
346 }
catch (\Phpfastcache\Exceptions\PhpfastcacheIOException $e) {
347 if (!$this->config->installer_running) {
364 $config = new \Phpfastcache\Drivers\Memstatic\Config();
366 $config->setUseStaticItemCaching(
true);
367 $config->setItemDetailedDate(
true);
381 $config = new \Phpfastcache\Drivers\Devnull\Config();
394 return class_exists(
'Memcached');
405 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
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.