Elgg  Version 3.0
CacheCollection.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Cache;
4 
6 use Elgg\Config;
7 
11 abstract class CacheCollection {
12 
16  protected $caches = [];
17 
21  protected $config;
22 
28  public function __construct(Config $config) {
29  $this->config = $config;
30  }
31 
35  public function __get($name) {
36  return $this->get($name);
37  }
38 
46  abstract protected function create($namespace);
47 
56  public function get($namespace) {
57  if (!isset($this->caches[$namespace])) {
58  $this->caches[$namespace] = $this->create($namespace);
59  }
60 
61  return $this->caches[$namespace];
62  }
63 
68  public function clear() {
69  foreach ($this->caches as $cache) {
70  $cache->clear();
71  }
72  }
73 
78  public function disable() {
79  foreach ($this->caches as $cache) {
80  $cache->disable();
81  }
82  }
83 
88  public function enable() {
89  foreach ($this->caches as $cache) {
90  $cache->enable();
91  }
92  }
93 
94 }
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
disable()
Disable all persistent caches.
enable()
Enable all persistent caches.
create($namespace)
Create a new cache under a namespace.
trait Cacheable
Utility trait for injecting cache.
Definition: Cacheable.php:11
clear()
Clear all persistent caches.
__construct(Config $config)
Constructor.
A collection of composite caches.