/** * Updates the appropriate cache file * * @param string title of the datastore item * @param mixed The data associated with the title * * @return void */ public function build($title = '', $data = '', $unserialize = 0) { parent::build($title, $data, $unserialize); $this->storeWinCache($title, $data); }
/** * Updates the appropriate cache file * * @param string title of the datastore item * @param mixed The data associated with the title * * @return void */ public function build($title = '', $data = '', $unserialize = 0) { parent::build($title, $data, $unserialize); $this->storeEAccelerator($title, $data); }
/** * Updates the appropriate cache file * * @param string title of the datastore item * @param mixed The data associated with the title * * @return void */ public function build($title = '', $data = '', $unserialize = 0) { parent::build($title, $data, $unserialize); if (!in_array($title, $this->cacheableitems)) { return; } if (!file_exists($this->datastoreLocation . '/datastore_cache.php')) { // file doesn't exist so don't try to write to it return; } $data_code = var_export(unserialize(trim($data)), true); if ($this->lock()) { $cache = file_get_contents($this->datastoreLocation . '/datastore_cache.php'); // this is equivalent to the old preg_match system, but doesn't have problems with big files (#23186) $open_match = strpos($cache, "### start {$title} ###"); if ($open_match) { // matched and not at the beginning $preceding = $cache[$open_match - 1]; if ($preceding != "\n" and $preceding != "\r") { $open_match = false; } } if ($open_match) { $close_match = strpos($cache, "### end {$title} ###", $open_match); if ($close_match) { // matched and not at the beginning $preceding = $cache[$close_match - 1]; if ($preceding != "\n" and $preceding != "\r") { $close_match = false; } } } // if we matched the beginning and end, then update the cache if (!empty($open_match) and !empty($close_match)) { $replace_start = $open_match - 1; // include the \n $replace_end = $close_match + strlen("### end {$title} ###"); $cache = substr_replace($cache, "\n### start {$title} ###\n\${$title} = {$data_code};\n### end {$title} ###", $replace_start, $replace_end - $replace_start); } // try an atomic operation first, if that fails go for the old method $atomic = false; if ($fp = @fopen($this->datastoreLocation . '/datastore_cache_atomic.php', 'w')) { fwrite($fp, $cache); fclose($fp); $atomic = $this->atomic_move($this->datastoreLocation . '/datastore_cache_atomic.php', $this->datastoreLocation . '/datastore_cache.php'); } if (!$atomic and $fp = @fopen($this->datastoreLocation . '/datastore_cache.php', 'w')) { fwrite($fp, $cache); fclose($fp); } $this->unlock(); // /* insert query */ $this->db_assertor->assertQuery('replace_adminutil', array('text' => $cache)); } else { trigger_error('Could not obtain file lock', E_USER_ERROR); } }