var $cache_pointer = false;
var $cache_data = "";
var $cache_version = "";
+ var $cache_file = "";
// Constructor
function mxchange_cache($interval, $path, $tested) {
}
}
- function cache_file($file, $ignore_ctime=false) {
- global $INC;
+ // Checks validity of cache file and if content is given
+ function cache_file ($file, $forceContent = false) {
+ // Remember cache file
+ $this->cache_file = $file;
+
// Construct FQFN (full qualified file name)
$inc = $this->cache_path.$file.".cache";
$this->cache_ctime = $ctime;
// Is the cache file outdated?
- if (((time() - $ctime) >= $this->update_interval) && (!$ignore_ctime)) {
+ if (($status) && ((time() - $ctime) >= $this->update_interval)) {
// Ok, we need an update!
$status = false;
- }
+ } // END - if
// Return status
return $status;
$cache_version = null;
// Load cache file
- $this->cache_data = implode("", file($this->cache_inc));
+ $this->cache_data[$this->cache_file] = implode("", file($this->cache_inc));
// Execute cache file
- eval($this->cache_data);
+ eval($this->cache_data[$this->cache_file]);
if (is_array($data)) {
// Cache data
- $this->cache_data = $data;
+ $this->cache_data[$this->cache_file] = $data;
// Cache version found?
- if ((isset($cache_version)) && (is_array($cache_version))) {
+ if ((is_array($cache_version)) && (count($cache_version) > 0)) {
// Remember it as well...
- $this->cache_version = $cache_version;
- } // END - if
+ $this->cache_version[$this->cache_file] = $cache_version;
+ } else {
+ // Invalid cache so destroy it
+ $this->cache_destroy();
+
+ // Clear cached data
+ $this->cache_data[$this->cache_file] = array();
+ }
// Return cache
- return $this->cache_data;
+ return $this->cache_data[$this->cache_file];
} else {
// Cache problem detected!
$this->cache_destroy();
}
}
- function cache_remove($search, $data, $array)
- {
+ function cache_remove($search, $data, $array) {
global $ARRAY;
if ((FILE_READABLE($this->cache_inc)) && (is_writeable($this->cache_inc))) {
// Load cache into dummy array
}
}
- function cache_replace($search, $replace, $search_key, $array)
- {
+ function cache_replace($search, $replace, $search_key, $array) {
global $ARRAY;
if ((FILE_READABLE($this->cache_inc)) && (is_writeable($this->cache_inc)))
{
// Get extension version
$ext_ver = GET_EXT_VERSION($ext_name);
- //* DEBUG: */ echo __METHOD__.": ext_name={$ext_name},ext_ver={$ext_ver},cache_version={$this->cache_version}<br />\n";
// Compare both
- return ((isset($this->cache_version[$ext_name])) && ($this->cache_version[$ext_name] == $ext_ver));
+ return ((isset($this->cache_version[$this->cache_file][$ext_name])) && ($this->cache_version[$this->cache_file][$ext_name] == $ext_ver));
}
function add_raw_row ($key, $value) {