61 parent::__construct();
80 if ($this->disabled) {
95 return $this->pool->save(
$item);
106 if ($this->disabled) {
111 if (!
$item->isHit()) {
115 if ($this->validate_lastcache && $this->config->lastcache) {
118 if (
$item->getCreationDate()->getTimestamp() < $expiration_date->getTimestamp()) {
132 if ($this->disabled) {
144 return $this->pool->clear();
198 return "{$this->getNamespace()}_{$id}";
213 if (!is_string(
$key) && !is_int(
$key)) {
217 return str_replace([
'{',
'}',
'(',
')',
'/',
'\\',
'@',
':'],
'_',
"{$key}");
235 $drivers = array_filter($drivers);
237 if (empty($drivers)) {
241 if (!empty($ephemeral)) {
242 $drivers[] = $ephemeral;
246 if (empty($drivers)) {
250 if (
count($drivers) === 1) {
251 return array_shift($drivers);
254 $cluster =
new ClusterAggregator($this->
getNamespace());
255 foreach ($drivers as $driver) {
256 $cluster->aggregateDriver($driver);
259 $cluster_driver = $cluster->getCluster();
261 $cluster_driver->getConfig()->setPreventCacheSlams(
true);
262 $cluster_driver->getConfig()->setDefaultChmod(0770);
263 $cluster_driver->getConfig()->setUseStaticItemCaching(
true);
264 $cluster_driver->getConfig()->setItemDetailedDate(
true);
266 return $cluster_driver;
278 if (!extension_loaded(
'apc') || !ini_get(
'apc.enabled')) {
282 elgg_deprecated_notice(
'The APC driver for caching is no longer available. Switch to an alternative method for caching.',
'4.1');
296 if (!self::isRedisAvailable()) {
317 if (!self::isMemcacheAvailable()) {
345 }
catch (\
Phpfastcache\Exceptions\PhpfastcacheIOException $e) {
346 if (!$this->config->installer_running) {
370 }
catch (\
Phpfastcache\Exceptions\PhpfastcacheIOException $e) {
371 if (!$this->config->installer_running) {
388 $config = new \Phpfastcache\Drivers\Memstatic\Config();
390 $config->setUseStaticItemCaching(
true);
391 $config->setItemDetailedDate(
true);
405 $config = new \Phpfastcache\Drivers\Devnull\Config();
418 return class_exists(
'Memcached');
429 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.
elgg_deprecated_notice(string $msg, string $dep_version)
Log a notice about deprecated use of a function, view, etc.
getNamespace()
Get the namespace currently defined.
if(elgg_trigger_plugin_hook('usersettings:save', 'user', $hooks_params, true)) foreach($request->validation() ->all() as $item) $data
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.
setNamespace($namespace= 'default')
Set the namespace of this cache.
sanitizeItemKey($key)
Sanitizes item key for cache.
buildMemcachedDriver()
Builds Memcached driver.
static getInstance(string $driver,?ConfigurationOptionInterface $config=null,?string $instanceId=null)
static fromElggConfig(string $namespace,\Elgg\Config $config)
Factory to return a config object to be used when starting a driver.
buildApcDriver()
Builds APC driver.
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
save($key, $data, $ttl=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.
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
const ELGG_CACHE_LOCALFILESYSTEM
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif($item instanceof ElggRelationship) elseif(is_callable([$item, 'getType']))
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.