59 parent::__construct();
85 if ($this->disabled) {
89 if (!is_string(
$key) && !is_int(
$key)) {
90 throw new \InvalidArgumentException(
'key must be string or integer');
109 public function load(
$key, $invalidation_method = null) {
110 if ($this->disabled) {
114 if (!is_string(
$key) && !is_int(
$key)) {
115 throw new \InvalidArgumentException(
'key must be string or integer');
120 if (is_array($invalidation_method)) {
121 call_user_func_array([
$item,
'setInvalidationMethod'], $invalidation_method);
125 if (
$item->isMiss()) {
130 }
catch (\Error $e) {
133 elgg_log(__METHOD__ .
" failed for key: {$this->getNamespace()}/{$key} with error: {$e->getMessage()}",
'ERROR');
150 if ($this->disabled) {
154 if (!is_string(
$key) && !is_int(
$key)) {
155 throw new \InvalidArgumentException(
'key must be string or integer');
204 return "/{$this->getNamespace()}/$key";
220 $drivers = array_filter($drivers);
222 if (empty($drivers)) {
223 throw new \ConfigurationException(
"Unable to initialize composite cache without drivers");
226 if (count($drivers) > 1) {
227 $driver =
new Composite([
228 'drivers' => $drivers,
231 $driver = array_shift($drivers);
234 return new Pool($driver);
246 if (!extension_loaded(
'apc') || !ini_get(
'apc.enabled')) {
262 if (!$this->config->redis || empty($this->config->redis_servers)) {
267 'servers' => $this->config->redis_servers,
280 if (!$this->config->memcache || empty($this->config->memcache_servers)) {
284 $has_class = class_exists(
'Memcache') || class_exists(
'Memcached');
289 return new Memcache([
290 'servers' => $this->config->memcache_servers,
292 'prefix_key' => $this->config->memcache_namespace_prefix,
306 $path = $this->config->cacheroot ? : $this->config->dataroot;
311 return new FileSystem([
325 return new Ephemeral();
337 return new BlackHole();
$ttl
TTL of saved items (default timeout after a day to prevent anything getting too stale) ...
load($key, $invalidation_method=null)
Load data from the cache using a given key.
getNamespace()
Get the namespace currently defined.
getPool()
Returns cache pool.
if(elgg_trigger_plugin_hook('usersettings:save', 'user', $hooks_params, true)) foreach($request->validation() ->all() as $item) $data
const ELGG_CACHE_BLACK_HOLE
Cache init values.
buildEphemeralDriver()
Builds in-memory driver.
buildMemcachedDriver()
Builds Memcached driver.
namespaceKey($key)
Namespace the key.
clear()
Clear out all the contents of the cache.
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.
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
createPool()
Create a new composite stash pool.
const ELGG_CACHE_PERSISTENT
const ELGG_CACHE_FILESYSTEM
buildRedisDriver()
Builds Redis driver.
setNamespace($namespace="default")
Set the namespace of this cache.
buildBlackHoleDriver()
Builds null cache driver.
buildFileSystemDriver()
Builds file system driver.
__construct($namespace, Config $config, $flags)
Constructor.