Elgg  Version 4.3
CacheCollection.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Cache;
4 
5 use Elgg\Config;
6 
10 abstract class CacheCollection {
11 
15  protected $caches = [];
16 
20  protected $config;
21 
27  public function __construct(Config $config) {
28  $this->config = $config;
29  }
30 
34  public function __get($name) {
35  return $this->get($name);
36  }
37 
45  abstract protected function create($namespace);
46 
55  public function get($namespace) {
56  if (!isset($this->caches[$namespace])) {
57  $this->caches[$namespace] = $this->create($namespace);
58  }
59 
60  return $this->caches[$namespace];
61  }
62 
67  public function clear() {
68  foreach ($this->caches as $cache) {
69  $cache->clear();
70  }
71  }
72 
78  public function invalidate() {
79  foreach ($this->caches as $cache) {
80  $cache->invalidate();
81  }
82  }
83 
89  public function purge() {
90  foreach ($this->caches as $cache) {
91  $cache->purge();
92  }
93  }
94 
99  public function disable() {
100  foreach ($this->caches as $cache) {
101  $cache->disable();
102  }
103  }
104 
109  public function enable() {
110  foreach ($this->caches as $cache) {
111  $cache->enable();
112  }
113  }
114 
115 }
disable()
Disable all persistent caches.
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
enable()
Enable all persistent caches.
create($namespace)
Create a new cache under a namespace.
clear()
Clear all persistent caches.
purge()
Purge all caches.
__construct(Config $config)
Constructor.
invalidate()
Invalidate all caches.
A collection of composite caches.