Google_Cache_Apc

A persistent storage class based on the APC cache, which is not really very persistent, as soon as you restart your web server the storage will be wiped, however for debugging and/or speed it can be useful, and cache is a lot cheaper then storage.

Defined (1)

The class is defined in the following location(s).

/lib/Google/Cache/Apc.php  
  1. class Google_Cache_Apc extends Google_Cache_Abstract 
  2. public function __construct(Google_Client $client) 
  3. if (! function_exists('apc_add') ) { 
  4. throw new Google_Cache_Exception("Apc functions not available"); 
  5.  
  6. /** 
  7. * @inheritDoc 
  8. */ 
  9. public function get($key, $expiration = false) 
  10. $ret = apc_fetch($key); 
  11. if ($ret === false) { 
  12. return false; 
  13. if (is_numeric($expiration) && (time() - $ret['time'] > $expiration)) { 
  14. $this->delete($key); 
  15. return false; 
  16. return $ret['data']; 
  17.  
  18. /** 
  19. * @inheritDoc 
  20. */ 
  21. public function set($key, $value) 
  22. $rc = apc_store($key, array('time' => time(), 'data' => $value)); 
  23. if ($rc == false) { 
  24. throw new Google_Cache_Exception("Couldn't store data"); 
  25.  
  26. /** 
  27. * @inheritDoc 
  28. * @param String $key 
  29. */ 
  30. public function delete($key) 
  31. apc_delete($key);