Elgg  Version 2.3
cache.php
Go to the documentation of this file.
1 <?php
10 /* Filepath Cache */
11 
21  return _elgg_services()->fileCache;
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 
61  return _elgg_services()->systemCache->isEnabled();
62 }
63 
73  _elgg_services()->systemCache->enable();
74 }
75 
85  _elgg_services()->systemCache->disable();
86 }
87 
88 /* Simplecache */
89 
108 function elgg_register_simplecache_view($view_name) {
109  _elgg_services()->simpleCache->registerView($view_name);
110 }
111 
136 function elgg_get_simplecache_url($view, $subview = '') {
137  return _elgg_services()->simpleCache->getUrl($view, $subview);
138 }
139 
147  return _elgg_services()->simpleCache->isEnabled();
148 }
149 
158  _elgg_services()->simpleCache->enable();
159 }
160 
171  _elgg_services()->simpleCache->disable();
172 }
173 
185 function _elgg_rmdir($dir, $empty = false) {
186  if (!$dir) {
187  // realpath can return false
188  _elgg_services()->logger->warn(__FUNCTION__ . ' called with empty $dir');
189  return true;
190  }
191  $files = array_diff(scandir($dir), array('.', '..'));
192 
193  foreach ($files as $file) {
194  if (is_dir("$dir/$file")) {
195  _elgg_rmdir("$dir/$file");
196  } else {
197  unlink("$dir/$file");
198  }
199  }
200 
201  if ($empty) {
202  return true;
203  }
204 
205  return rmdir($dir);
206 }
207 
216  _elgg_services()->simpleCache->invalidate();
217 }
218 
225 function elgg_flush_caches() {
226  _elgg_services()->events->trigger('cache:flush', 'system');
227 }
228 
236  $link = elgg_get_root_path() . 'cache/';
237  $target = elgg_get_cache_path() . 'views_simplecache/';
238  return is_dir($link) && realpath($target) == realpath($link);
239 }
240 
250  _elgg_services()->entityCache->remove($entity_guid);
251 }
252 
259 function _elgg_cache_init() {
260  _elgg_services()->simpleCache->init();
261  _elgg_services()->systemCache->init();
262 }
263 
264 return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
265  $events->registerHandler('ready', 'system', '_elgg_cache_init');
266 
267  // register plugin hooks for cache reset
268  $events->registerHandler('cache:flush', 'system', 'elgg_reset_system_cache');
269  $events->registerHandler('cache:flush', 'system', 'elgg_invalidate_simplecache');
270 };
elgg_enable_system_cache()
Enables the system disk cache.
Definition: cache.php:72
$view
Definition: crop.php:34
elgg_reset_system_cache()
Reset the system cache by deleting the caches.
Definition: cache.php:29
_elgg_is_cache_symlinked()
Checks if /cache directory has been symlinked to views simplecache directory.
Definition: cache.php:235
_elgg_cache_init()
Initializes the simplecache lastcache variable and creates system cache files when appropriate...
Definition: cache.php:259
if(!array_key_exists($filename, $text_files)) $file
_elgg_invalidate_cache_for_entity($entity_guid)
Invalidate entity cache.
Definition: cache.php:249
elgg_invalidate_simplecache()
Deletes all cached views in the simplecache and sets the lastcache and lastupdate time to 0 for every...
Definition: cache.php:215
elgg_register_simplecache_view($view_name)
Registers a view to simple cache.
Definition: cache.php:108
elgg_disable_system_cache()
Disables the system disk cache.
Definition: cache.php:84
elgg_get_simplecache_url($view, $subview= '')
Get the URL for the cached view.
Definition: cache.php:136
elgg_get_system_cache()
Returns an object suitable for caching system information.
Definition: cache.php:20
$data
Definition: opendd.php:13
$link
Definition: container.php:14
$entity_guid
Definition: save.php:9
if(!($comment instanceof\ElggComment)||!$comment->canEdit()) $target
Definition: edit.php:17
elgg_get_cache_path()
Get the cache directory path for this installation.
elgg_get_root_path()
Get the root directory path for this installation.
_elgg_rmdir($dir, $empty=false)
Recursively deletes a directory, including all hidden files.
Definition: cache.php:185
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
Definition: autoloader.php:17
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:146
elgg_disable_simplecache()
Disables the simple cache.
Definition: cache.php:170
elgg_save_system_cache($type, $data)
Saves a system cache.
Definition: cache.php:40
elgg_is_system_cache_enabled()
Is system cache enabled.
Definition: cache.php:60
elgg_enable_simplecache()
Enables the simple cache.
Definition: cache.php:157
foreach($resources as $id=> $href) if(!empty($resources_html)) $files
Definition: details.php:141
elgg_flush_caches()
Flush all the registered caches.
Definition: cache.php:225
if(!$display_name) $type
Definition: delete.php:27