Elgg  Version 4.3
Cacheable.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Traits;
4 
6 use ElggCache;
7 
13 trait Cacheable {
14 
18  protected $cache;
19 
27  public function setCache(ElggCache $cache) {
28  $this->cache = $cache;
29  }
30 
36  public function getCache() {
37  if (!isset($this->cache)) {
38  return new CompositeCache('void', _elgg_services()->config, ELGG_CACHE_BLACK_HOLE);
39  }
40 
41  return $this->cache;
42  }
43 }
setCache(ElggCache $cache)
Set cache.
Definition: Cacheable.php:27
const ELGG_CACHE_BLACK_HOLE
Cache init values.
Definition: constants.php:136
Composite cache pool.
getCache()
Get cache.
Definition: Cacheable.php:36
_elgg_services()
Get the global service provider.
Definition: elgglib.php:638