Elgg  Version master
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 array $caches = [];
16 
22  public function __construct(protected Config $config) {
23  }
24 
28  public function __get($name) {
29  return $this->get($name);
30  }
31 
39  abstract protected function create($namespace);
40 
49  public function get($namespace) {
50  if (!isset($this->caches[$namespace])) {
51  $this->caches[$namespace] = $this->create($namespace);
52  }
53 
54  return $this->caches[$namespace];
55  }
56 
62  public function clear() {
63  foreach ($this->caches as $cache) {
64  $cache->clear();
65  }
66  }
67 
73  public function invalidate() {
74  foreach ($this->caches as $cache) {
75  $cache->invalidate();
76  }
77  }
78 
84  public function purge() {
85  foreach ($this->caches as $cache) {
86  $cache->purge();
87  }
88  }
89 
95  public function disable() {
96  foreach ($this->caches as $cache) {
97  $cache->disable();
98  }
99  }
100 
106  public function enable() {
107  foreach ($this->caches as $cache) {
108  $cache->enable();
109  }
110  }
111 }
disable()
Disable all persistent caches.
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
enable()
Enable all persistent caches.
__construct(protected Config $config)
Constructor.
$config
Advanced site settings, debugging section.
Definition: debugging.php:6
create($namespace)
Create a new cache under a namespace.
clear()
Clear all persistent caches.
purge()
Purge all caches.
invalidate()
Invalidate all caches.
A collection of composite caches.