Elgg  Version 3.0
DefinitionCache.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Di;
4 
10 use Elgg\Cacheable;
11 
17 class DefinitionCache implements Cache,
18  FlushableCache,
19  ClearableCache,
20  MultiGetCache,
21  MultiPutCache {
22 
23  use Cacheable;
24 
30  public function __construct(\ElggCache $cache) {
31  $this->cache = $cache;
32  }
33 
37  public function fetch($id) {
38  $value = $this->cache->load($id);
39  if (!$value) {
40  return false;
41  }
42  return $value;
43  }
44 
48  public function contains($id) {
49  return $this->fetch($id) !== null;
50  }
51 
55  public function save($id, $data, $lifeTime = 0) {
56  return $this->cache->save($id, $data, $lifeTime ? : null);
57  }
58 
62  public function delete($id) {
63  return $this->cache->delete($id);
64  }
65 
69  public function getStats() {
70  return null;
71  }
72 
76  public function deleteAll() {
77  return $this->cache->clear();
78  }
79 
83  public function flushAll() {
84  return $this->cache->clear();
85  }
86 
90  public function fetchMultiple(array $keys) {
91  $values = [];
92  foreach ($keys as $key) {
93  $values[] = $this->cache->load($key);
94  }
95 
96  return $values;
97  }
98 
102  public function saveMultiple(array $keysAndValues, $lifetime = 0) {
103  foreach ($keysAndValues as $key => $value) {
104  $this->save($key, $value, $lifetime);
105  }
106 
107  return true;
108  }
109 }
if(elgg_trigger_plugin_hook('usersettings:save', 'user', $hooks_params, true)) foreach($request->validation() ->all() as $item) $data
Definition: save.php:57
$keys
Definition: access.php:34
__construct(\ElggCache $cache)
Constructor.
$id
River item delete action.
Definition: delete.php:6
trait Cacheable
Utility trait for injecting cache.
Definition: Cacheable.php:11
fetchMultiple(array $keys)
{}
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:55
$value
Definition: debugging.php:7
saveMultiple(array $keysAndValues, $lifetime=0)
{}
save($id, $data, $lifeTime=0)
{}