cache.php 764 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * 缓存操作
  4. *
  5. */
  6. defined('InShopNC') or exit('Access Invalid!');
  7. class Cache
  8. {
  9. protected $params;
  10. protected $enable;
  11. protected $handler;
  12. /**
  13. * 实例化缓存驱动
  14. *
  15. * @param unknown_type $type
  16. * @param unknown_type $args
  17. * @return unknown
  18. */
  19. public function connect($type,$args = array()){
  20. if (empty($type)) $type = C('cache_open') ? 'redis' : 'file';
  21. $type = strtolower($type);
  22. $class = ucwords($type);
  23. if (!class_exists($class)){
  24. import('cache.cache#'.$type);
  25. }
  26. return new $class($args);
  27. }
  28. /**
  29. * 取得实例
  30. *
  31. * @return object
  32. */
  33. public static function getInstance(){
  34. $args = func_get_args();
  35. return get_obj_instance(__CLASS__,'connect',$args);
  36. }
  37. }