22 import(
'lib.pkp.classes.cache.GenericCache');
38 function __construct($context, $cacheId, $fallback, $path) {
39 parent::__construct($context, $cacheId, $fallback);
41 $this->filename = $path . DIRECTORY_SEPARATOR .
"fc-$context-" . str_replace(
'/',
'.', $cacheId) .
'.php';
44 if (($fp = @fopen($this->filename,
'r')) !==
false) {
46 $this->cache = include($this->filename);
59 if (function_exists(
'opcache_invalidate')) opcache_invalidate($this->filename,
true);
60 @unlink($this->filename);
67 function getCache($id) {
68 if (!isset($this->cache))
return $this->cacheMiss;
69 return (isset($this->cache[$id])?$this->cache[$id]:
null);
78 function setCache($id, $value) {
86 function setEntireCache($contents) {
87 if (file_put_contents(
89 '<?php return ' . var_export($contents,
true) .
';',
93 if ($umask) @chmod($this->filename, FILE_MODE_MASK & ~$umask);
95 $this->cache = $contents;
103 function getCacheTime() {
104 $result = @filemtime($this->filename);
105 if ($result ===
false)
return null;
106 return ((
int) $result);
113 if (!isset($this->cache)) {