Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
APCCache.inc.php
1 <?php
2 
18 import('lib.pkp.classes.cache.GenericCache');
19 
20 class apc_false {};
21 
22 class APCCache extends GenericCache {
30  parent::GenericCache($context, $cacheId, $fallback);
31  }
32 
36  function flush() {
37  $prefix = INDEX_FILE_LOCATION . ':' . $this->getContext() . ':' . $this->getCacheId();
38  $info = apc_cache_info('user');
39  foreach ($info['cache_list'] as $entry) {
40  if (substr($entry['info'], 0, strlen($prefix)) == $prefix) apc_delete($entry['info']);
41  }
42  }
43 
49  function getCache($id) {
50  $key = INDEX_FILE_LOCATION . ':'. $this->getContext() . ':' . $this->getCacheId() . ':' . $id;
51  $returner = unserialize(apc_fetch($key));
52  if ($returner === false) return $this->cacheMiss;
53  if (get_class($returner) === 'apc_false') $returner = false;
54  return $returner;
55  }
56 
63  function setCache($id, $value) {
64  $key = INDEX_FILE_LOCATION . ':'. $this->getContext() . ':' . $this->getCacheId() . ':' . $id;
65  if ($value === false) $value = new apc_false;
66  apc_store($key, serialize($value));
67  }
68 
74  function getCacheTime() {
75  return null;
76  }
77 
83  function setEntireCache(&$contents) {
84  foreach ($contents as $id => $value) {
85  $this->setCache($id, $value);
86  }
87  }
88 }
89 
90 ?>
getCache($id)
setCache($id, $value)
APCCache($context, $cacheId, $fallback)
setEntireCache(&$contents)
Provides caching based on APC&#39;s variable store.
Provides implementation-independent caching. Although this class is intended to be overridden with a ...