9 use Phpfastcache\CacheManager;
 
   10 use Phpfastcache\Cluster\ClusterAggregator;
 
   11 use Phpfastcache\Config\ConfigurationOption;
 
   12 use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface;
 
   13 use Phpfastcache\Exceptions\PhpfastcacheRootException;
 
   31     protected int $ttl = 86400;
 
   46     public function __construct(
protected string $namespace, 
protected Config $config, 
protected int $flags, 
protected bool $validate_lastcache = 
true) {
 
   60         if ($this->disabled) {
 
   69         if (is_int($expire_after)) {
 
   70             $item->expiresAfter($expire_after);
 
   72             $item->expiresAt($expire_after);
 
   75         return $this->pool->save(
$item);
 
   86         if ($this->disabled) {
 
   92             if (!
$item->isHit()) {
 
   96             if ($this->validate_lastcache && $this->config->lastcache) {
 
   99                 if (
$item->getCreationDate()->getTimestamp() < $expiration_date->getTimestamp()) {
 
  106         } 
catch (PhpfastcacheRootException $e) {
 
  108             elgg_log($e->getMessage(), \Psr\Log\LogLevel::ERROR);
 
  117         if ($this->disabled) {
 
  128         return $this->pool->clear();
 
  158         $this->namespace = $namespace;
 
  180         return "{$this->getNamespace()}_{$id}";
 
  199         return str_replace([
'{', 
'}', 
'(', 
')', 
'/', 
'\\', 
'@', 
':'], 
'_', 
"{$key}");
 
  208     protected function createPool(): ExtendedCacheItemPoolInterface {
 
  211         $drivers[] = $this->buildRedisDriver();
 
  212         $drivers[] = $this->buildMemcachedDriver();
 
  213         $drivers[] = $this->buildFileSystemDriver();
 
  214         $drivers[] = $this->buildLocalFileSystemDriver();
 
  215         $drivers[] = $this->buildBlackHoleDriver();
 
  216         $drivers = array_filter($drivers);
 
  218         if (empty($drivers)) {
 
  221             $ephemeral = $this->buildEphemeralDriver();
 
  222             if (!empty($ephemeral)) {
 
  223                 $drivers[] = $ephemeral;
 
  227         if (empty($drivers)) {
 
  231         if (count($drivers) === 1) {
 
  232             return array_shift($drivers);
 
  235         $cluster = 
new ClusterAggregator($this->getNamespace());
 
  236         foreach ($drivers as $driver) {
 
  237             $cluster->aggregateDriver($driver);
 
  240         $cluster_driver = $cluster->getCluster();
 
  241         $cluster_driver->setConfig(
new ConfigurationOption([
 
  242             'useStaticItemCaching' => 
true,
 
  243             'itemDetailedDate' => 
true,
 
  246         return $cluster_driver;
 
  254         if (!($this->flags & self::CACHE_PERSISTENT)) {
 
  258         if (!self::isRedisAvailable()) {
 
  267         return CacheManager::getInstance(
'Redis', 
$config, $this->prefixInstanceId(
'redis'));
 
  275         if (!($this->flags & self::CACHE_PERSISTENT)) {
 
  279         if (!self::isMemcacheAvailable()) {
 
  288         return CacheManager::getInstance(
'Memcached', 
$config, $this->prefixInstanceId(
'memcache'));
 
  296         if (!($this->flags & self::CACHE_FILESYSTEM)) {
 
  306             return CacheManager::getInstance(
'Files', 
$config, $this->prefixInstanceId(
'files'));
 
  307         } 
catch (\Phpfastcache\Exceptions\PhpfastcacheIOException $e) {
 
  308             if (!$this->config->installer_running) {
 
  309                 elgg_log($e, \Psr\Log\LogLevel::ERROR);
 
  321         if (!($this->flags & self::CACHE_LOCALFILESYSTEM)) {
 
  331             return CacheManager::getInstance(
'Files', 
$config, $this->prefixInstanceId(
'local_files'));
 
  332         } 
catch (\Phpfastcache\Exceptions\PhpfastcacheIOException $e) {
 
  333             if (!$this->config->installer_running) {
 
  334                 elgg_log($e, \Psr\Log\LogLevel::ERROR);
 
  346         if (!($this->flags & self::CACHE_RUNTIME)) {
 
  350         $config = new \Phpfastcache\Drivers\Memory\Config();
 
  352         $config->setUseStaticItemCaching(
true);
 
  353         $config->setItemDetailedDate(
true);
 
  355         return CacheManager::getInstance(
'Memory', 
$config, $this->prefixInstanceId(
'memory'));
 
  363         if (!($this->flags & self::CACHE_BLACK_HOLE)) {
 
  367         $config = new \Phpfastcache\Drivers\Devnull\Config();
 
  369         return CacheManager::getInstance(
'Devnull', 
$config, $this->prefixInstanceId(
'devnull'));
 
  380         return class_exists(
'Memcached');
 
  391         return extension_loaded(
'Redis');
 
$id
Generic annotation delete action.
return[ 'admin/delete_admin_notices'=>['access'=> 'admin'], 'admin/menu/save'=>['access'=> 'admin'], 'admin/plugins/activate'=>['access'=> 'admin'], 'admin/plugins/activate_all'=>['access'=> 'admin'], 'admin/plugins/deactivate'=>['access'=> 'admin'], 'admin/plugins/deactivate_all'=>['access'=> 'admin'], 'admin/plugins/set_priority'=>['access'=> 'admin'], 'admin/security/security_txt'=>['access'=> 'admin'], 'admin/security/settings'=>['access'=> 'admin'], 'admin/security/regenerate_site_secret'=>['access'=> 'admin'], 'admin/site/cache/invalidate'=>['access'=> 'admin'], 'admin/site/flush_cache'=>['access'=> 'admin'], 'admin/site/icons'=>['access'=> 'admin'], 'admin/site/set_maintenance_mode'=>['access'=> 'admin'], 'admin/site/set_robots'=>['access'=> 'admin'], 'admin/site/theme'=>['access'=> 'admin'], 'admin/site/unlock_upgrade'=>['access'=> 'admin'], 'admin/site/settings'=>['access'=> 'admin'], 'admin/upgrade'=>['access'=> 'admin'], 'admin/upgrade/reset'=>['access'=> 'admin'], 'admin/user/ban'=>['access'=> 'admin'], 'admin/user/bulk/ban'=>['access'=> 'admin'], 'admin/user/bulk/delete'=>['access'=> 'admin'], 'admin/user/bulk/unban'=>['access'=> 'admin'], 'admin/user/bulk/validate'=>['access'=> 'admin'], 'admin/user/change_email'=>['access'=> 'admin'], 'admin/user/delete'=>['access'=> 'admin'], 'admin/user/login_as'=>['access'=> 'admin'], 'admin/user/logout_as'=>[], 'admin/user/makeadmin'=>['access'=> 'admin'], 'admin/user/resetpassword'=>['access'=> 'admin'], 'admin/user/removeadmin'=>['access'=> 'admin'], 'admin/user/unban'=>['access'=> 'admin'], 'admin/user/validate'=>['access'=> 'admin'], 'annotation/delete'=>[], 'avatar/upload'=>[], 'comment/save'=>[], 'diagnostics/download'=>['access'=> 'admin'], 'entity/chooserestoredestination'=>[], 'entity/delete'=>[], 'entity/mute'=>[], 'entity/restore'=>[], 'entity/subscribe'=>[], 'entity/trash'=>[], 'entity/unmute'=>[], 'entity/unsubscribe'=>[], 'login'=>['access'=> 'logged_out'], 'logout'=>[], 'notifications/mute'=>['access'=> 'public'], 'plugins/settings/remove'=>['access'=> 'admin'], 'plugins/settings/save'=>['access'=> 'admin'], 'plugins/usersettings/save'=>[], 'register'=>['access'=> 'logged_out', 'middleware'=>[\Elgg\Router\Middleware\RegistrationAllowedGatekeeper::class,],], 'river/delete'=>[], 'settings/notifications'=>[], 'settings/notifications/subscriptions'=>[], 'user/changepassword'=>['access'=> 'public'], 'user/requestnewpassword'=>['access'=> 'public'], 'useradd'=>['access'=> 'admin'], 'usersettings/save'=>[], 'widgets/add'=>[], 'widgets/delete'=>[], 'widgets/move'=>[], 'widgets/save'=>[],]
if(! $entity instanceof \ElggUser) $data
The Elgg cache base class.
buildFileSystemDriver()
Builds file system driver.
int $ttl
TTL of saved items (default timeout after a day to prevent anything getting too stale)
purge()
{Purge old/stale contents of the cache.bool}
save($key, $data, $expire_after=null)
Save data in a cache.
static isRedisAvailable()
Helper function to check if Redis is available.
createPool()
Create a new cluster/pool of drivers.
clear()
{Clear out all the contents of the cache.bool}
__construct(protected string $namespace, protected Config $config, protected int $flags, protected bool $validate_lastcache=true)
Constructor.
setNamespace($namespace='default')
Set the namespace of this cache.
buildEphemeralDriver()
Builds in-memory driver.
sanitizeItemKey($key)
Sanitizes item key for cache.
getNamespace()
Get the namespace currently defined.
static isMemcacheAvailable()
Helper function to check if memcache is available.
prefixInstanceId(string $id)
Prefixes instance ids with namespace.
buildRedisDriver()
Builds Redis driver.
invalidate()
{Invalidate the contents of the cache.bool}
const CACHE_LOCALFILESYSTEM
buildBlackHoleDriver()
Builds null cache driver.
buildMemcachedDriver()
Builds Memcached driver.
load($key)
Load data from the cache using a given key.
buildLocalFileSystemDriver()
Builds local file system driver.
static fromElggConfig(string $namespace, \Elgg\Config $config)
Factory to return a config object to be used when starting a driver.
static fromElggConfig(string $namespace, \Elgg\Config $config)
Factory to return a config object to be used when starting a driver.
static fromElggConfig(string $namespace, \Elgg\Config $config)
Factory to return a config object to be used when starting a driver.
static fromElggConfig(string $namespace, \Elgg\Config $config)
Factory to return a config object to be used when starting a driver.
A generic parent class for Configuration exceptions.
Exception thrown if an argument is not of the expected type.
Extension of the DateTime class to support formatting a date using the locale.
Functions for use as event handlers or other situations where you need a globally accessible callable...
static normalizeTime($time)
Returns DateTime object based on time representation.
$config
Advanced site settings, debugging section.
if($item instanceof \ElggEntity) elseif($item instanceof \ElggRiverItem) elseif($item instanceof \ElggRelationship) elseif(is_callable([ $item, 'getType']))
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
if($container instanceof ElggGroup && $container->guid !=elgg_get_page_owner_guid()) $key
if(parse_url(elgg_get_site_url(), PHP_URL_PATH) !=='/') if(file_exists(elgg_get_root_path() . 'robots.txt'))
Set robots.txt.