Elgg  Version master
CacheService.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Cache;
4 
11 abstract class CacheService {
12 
14 
15  protected bool $enabled = true;
16 
22  public function purge(): void {
23  $this->cache->purge();
24  }
25 
31  public function invalidate(): void {
32  $this->cache->invalidate();
33  }
34 
40  public function clear(): void {
41  $this->cache->clear();
42  }
43 
53  public function save(string $key, mixed $data, int|\DateTime $expire_after = null): bool {
54  return $this->isEnabled() && $this->cache->save($key, $data, $expire_after);
55  }
56 
64  public function load(string $key): mixed {
65  return $this->isEnabled() ? $this->cache->load($key) : null;
66  }
67 
75  public function delete(string $key): bool {
76  return $this->cache->delete($key);
77  }
78 
84  public function isEnabled(): bool {
85  return $this->enabled;
86  }
87 
93  public function enable(): void {
94  $this->enabled = true;
95  }
96 
102  public function disable(): void {
103  $this->enabled = false;
104  }
105 }
CompositeCache $cache
clear()
Clears the caches.
invalidate()
Invalidates the caches.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition: LICENSE.txt:215
Composite cache pool.
if(!$entity instanceof\ElggUser) $data
Definition: attributes.php:13
isEnabled()
Is the cache enabled.
save(string $key, mixed $data, int|\DateTime $expire_after=null)
Saves data in the cache.
disable()
Disables the cache.
enable()
Enables the cache.
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:44
purge()
Purges the caches.
Extension of the DateTime class to support formatting a date using the locale.
Definition: DateTime.php:12
load(string $key)
Retrieve the contents of a cached item.