Elgg  Version 1.11
cache.php
Go to the documentation of this file.
1 <?php
10 /* Filepath Cache */
11 
21  return _elgg_services()->systemCache->getFileCache();
22 }
23 
30  _elgg_services()->systemCache->reset();
31 }
32 
41  return _elgg_services()->systemCache->save($type, $data);
42 }
43 
51  return _elgg_services()->systemCache->load($type);
52 }
53 
63  _elgg_services()->systemCache->enable();
64 }
65 
75  _elgg_services()->systemCache->disable();
76 }
77 
78 /* Simplecache */
79 
98 function elgg_register_simplecache_view($view_name) {
99  _elgg_services()->simpleCache->registerView($view_name);
100 }
101 
118  return _elgg_services()->simpleCache->getUrl($type, $view);
119 }
120 
121 
129  return _elgg_services()->simpleCache->getRoot();
130 }
131 
149  if (preg_match('~(?:^|/)(css|js)(?:$|/)~', $view, $m)) {
150  return $m[1];
151  } else {
152  return 'unknown';
153  }
154 }
155 
163  return _elgg_services()->simpleCache->isEnabled();
164 }
165 
174  _elgg_services()->simpleCache->enable();
175 }
176 
187  _elgg_services()->simpleCache->disable();
188 }
189 
199 function _elgg_rmdir($dir) {
200  $files = array_diff(scandir($dir), array('.', '..'));
201 
202  foreach ($files as $file) {
203  if (is_dir("$dir/$file")) {
204  _elgg_rmdir("$dir/$file");
205  } else {
206  unlink("$dir/$file");
207  }
208  }
209 
210  return rmdir($dir);
211 }
212 
221  _elgg_services()->simpleCache->invalidate();
222 }
223 
230 function _elgg_cache_init() {
231  _elgg_services()->simpleCache->init();
232  _elgg_services()->systemCache->init();
233 }
234 
235 return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
236  $events->registerHandler('ready', 'system', '_elgg_cache_init');
237 };
elgg_enable_system_cache()
Enables the system disk cache.
Definition: cache.php:62
$view
Definition: crop.php:68
elgg_reset_system_cache()
Reset the system cache by deleting the caches.
Definition: cache.php:29
_elgg_cache_init()
Initializes the simplecache lastcache variable and creates system cache files when appropriate...
Definition: cache.php:230
elgg_invalidate_simplecache()
Deletes all cached views in the simplecache and sets the lastcache and lastupdate time to 0 for every...
Definition: cache.php:220
$m
Definition: metadata.php:11
elgg_register_simplecache_view($view_name)
Registers a view to simple cache.
Definition: cache.php:98
elgg_disable_system_cache()
Disables the system disk cache.
Definition: cache.php:74
elgg_get_system_cache()
Returns an object suitable for caching system information.
Definition: cache.php:20
$data
Definition: opendd.php:13
$files
Definition: crop.php:36
_elgg_get_view_filetype($view)
Returns the type of output expected from the view.
Definition: cache.php:148
elgg_get_simplecache_url($type, $view)
Definition: cache.php:117
_elgg_services()
Definition: autoloader.php:14
_elgg_get_simplecache_root()
Get the base url for simple cache requests.
Definition: cache.php:128
$type
Definition: add.php:8
elgg_load_system_cache($type)
Retrieve the contents of a system cache.
Definition: cache.php:50
elgg_is_simplecache_enabled()
Is simple cache enabled.
Definition: cache.php:162
elgg_disable_simplecache()
Disables the simple cache.
Definition: cache.php:186
elgg_save_system_cache($type, $data)
Saves a system cache.
Definition: cache.php:40
_elgg_rmdir($dir)
Recursively deletes a directory, including all hidden files.
Definition: cache.php:199
elgg_enable_simplecache()
Enables the simple cache.
Definition: cache.php:173