Elgg  Version 3.0
Cacheable.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg;
4 
6 use ElggCache;
7 
11 trait Cacheable {
12 
16  protected $cache;
17 
25  public function setCache(ElggCache $cache) {
26  $this->cache = $cache;
27  }
28 
33  public function getCache() {
34  if (!isset($this->cache)) {
35  return new CompositeCache('void', _elgg_config(), ELGG_CACHE_BLACK_HOLE);
36  }
37 
38  return $this->cache;
39  }
40 }
const ELGG_CACHE_BLACK_HOLE
Cache init values.
Definition: constants.php:147
Composite cache pool.
getCache()
Get cache.
Definition: Cacheable.php:33
Configuration exception.
_elgg_config()
Get the Elgg config service.
setCache(ElggCache $cache)
Set cache.
Definition: Cacheable.php:25