Elgg  Version 5.1
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 
68  public function clear() {
69  foreach ($this->caches as $cache) {
70  $cache->clear();
71  }
72  }
73 
79  public function invalidate() {
80  foreach ($this->caches as $cache) {
81  $cache->invalidate();
82  }
83  }
84 
90  public function purge() {
91  foreach ($this->caches as $cache) {
92  $cache->purge();
93  }
94  }
95 
101  public function disable() {
102  foreach ($this->caches as $cache) {
103  $cache->disable();
104  }
105  }
106 
112  public function enable() {
113  foreach ($this->caches as $cache) {
114  $cache->enable();
115  }
116  }
117 }
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.