C_Pope_Cache

The NextGEN Gallery C Pope Cache class.

Defined (1)

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

/pope/lib/class.pope_cache.php  
  1. class C_Pope_Cache 
  2. static $_instance = NULL; 
  3. static $_driver = NULL; 
  4. static $key_prefix = array('pope'); 
  5. static $enabled = TRUE; // the cache is not used at all 
  6. static $do_not_lookup = FALSE; // no lookups are made to the cache 
  7. static $force_update = FALSE; // force the cache to be updated 
  8. protected $_queue = array(); 
  9.  
  10. static function &get_instance($driver='C_Pope_Cache_SingleFile') 
  11. if (!isset(self::$_instance)) 
  12. self::$_instance = new C_Pope_Cache($driver); 
  13.  
  14. return self::$_instance; 
  15.  
  16. function __construct($driver = 'C_Pope_Cache_SingleFile') 
  17. if (is_null(self::$_driver)) 
  18. self::set_driver($driver); 
  19.  
  20. static function set_driver($class_name) 
  21. self::$_driver = $class_name; 
  22.  
  23. static function add_key_prefix($prefix) 
  24. self::$key_prefix[] = $prefix; 
  25. $driver = self::$_driver; 
  26. return call_user_func("{$driver}::add_key_prefix", $prefix); 
  27.  
  28. static function get($params, $default=NULL) 
  29. if (!self::$enabled) 
  30. return $default; 
  31. $cache = self::get_instance(); 
  32. $key = $cache->get_key_from_params($params); 
  33. if (self::$do_not_lookup) 
  34. return $default; 
  35. else 
  36. return $cache->lookup($key, $default); 
  37.  
  38. static function set($params, $value) 
  39. if (self::$enabled) 
  40. $cache = self::get_instance(); 
  41. $key = $cache->get_key_from_params($params); 
  42. $cache->update($key, $value); 
  43.  
  44. function get_key_from_params($params) 
  45. return md5(json_encode($params)); 
  46.  
  47. function lookup($key, $default=NULL) 
  48. $driver = self::$_driver; 
  49. return call_user_func("{$driver}::lookup", $key, $default); 
  50.  
  51. function update($key, $value) 
  52. $driver = self::$_driver; 
  53. return call_user_func("{$driver}::update", $key, $value); 
  54.  
  55. function flush() 
  56. $driver = self::$_driver; 
  57. return call_user_func("{$driver}::flush"); 
  58.