1: <?php
2:
3:
4: /**
5: * Cache provider based on APC interface. APC or APCu can be used.
6: * APC and APCu are not included in standard PHP, but are easily added with a pecl install.
7: */
8: class QCacheProviderAPC extends QAbstractCacheProvider {
9: /** @var int The lifetime of cached items. */
10: public static $ttl = 86400; // one day between cache drops
11:
12:
13: /**
14: * Get the object that has the given key from the cache
15: * @param string $strKey the key of the object in the cache
16: * @return object
17: */
18: public function Get($strKey) {
19: return apc_fetch($strKey);
20: }
21:
22: /**
23: * Set the object into the cache with the given key
24: * @param string $strKey the key to use for the object
25: * @param object $objValue the object to put in the cache
26: * @return void
27: */
28: public function Set($strKey, $objValue) {
29: apc_store ($strKey, $objValue, static::$ttl);
30:
31: }
32:
33: /**
34: * Delete the object that has the given key from the cache
35: * @param string $strKey the key of the object in the cache
36: * @return void
37: */
38: public function Delete($strKey) {
39: apc_delete($strKey);
40: }
41:
42: /**
43: * Invalidate all the objects in the cache
44: * @return void
45: */
46: public function DeleteAll() {
47: apc_clear_cache('user');
48: }
49: }