aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/cache.php
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2012-01-21 13:33:40 -0500
committerCash Costello <cash.costello@gmail.com>2012-01-21 13:33:40 -0500
commit7c962fa6cbaf687daafb8588ff601fe664e1392c (patch)
tree73f74da6403ad9d17edc055d6286faec2c7b442a /engine/lib/cache.php
parentb466d3e188a001f8d7ede1afbf3927c6dbdeae15 (diff)
downloadelgg-7c962fa6cbaf687daafb8588ff601fe664e1392c.tar.gz
elgg-7c962fa6cbaf687daafb8588ff601fe664e1392c.tar.bz2
moved cache loading out of plugin code
Diffstat (limited to 'engine/lib/cache.php')
-rw-r--r--engine/lib/cache.php49
1 files changed, 47 insertions, 2 deletions
diff --git a/engine/lib/cache.php b/engine/lib/cache.php
index cfda26e52..633c470eb 100644
--- a/engine/lib/cache.php
+++ b/engine/lib/cache.php
@@ -395,7 +395,40 @@ function elgg_invalidate_simplecache() {
return $return;
}
-function elgg_cache_init() {
+/**
+ * @see elgg_reset_system_cache()
+ * @access private
+ */
+function _elgg_load_cache() {
+ global $CONFIG;
+
+ $result = true;
+ $cache_types = array(
+ 'view_paths' => 'views',
+ 'view_types' => 'view_types',
+ );
+ $data = array();
+ foreach ($cache_types as $type => $var_name) {
+ $data[$var_name] = elgg_load_system_cache($type);
+ $result = $result && is_string($data[$var_name]);
+ }
+
+ if ($result) {
+ $CONFIG->system_cache_loaded = true;
+ foreach ($data as $name => $value) {
+ $CONFIG->$name = unserialize($value);
+ }
+ } else {
+ $CONFIG->system_cache_loaded = false;
+ }
+}
+
+/**
+ * @access private
+ */
+function _elgg_cache_init() {
+ global $CONFIG;
+
$viewtype = elgg_get_viewtype();
// Regenerate the simple cache if expired.
@@ -410,6 +443,18 @@ function elgg_cache_init() {
}
$CONFIG->lastcache = $lastcached;
}
+
+ // cache system data if enabled and not loaded
+ if ($CONFIG->system_cache_enabled && !$CONFIG->system_cache_loaded) {
+ $cache_types = array(
+ 'view_paths' => 'views',
+ 'view_types' => 'view_types',
+ );
+ $data = array();
+ foreach ($cache_types as $type => $var_name) {
+ elgg_save_system_cache($type, serialize($CONFIG->$var_name));
+ }
+ }
}
-elgg_register_event_handler('ready', 'system', 'elgg_cache_init'); \ No newline at end of file
+elgg_register_event_handler('ready', 'system', '_elgg_cache_init');