cache.php 770 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. {
  35. $args = func_get_args();
  36. return get_obj_instance(__CLASS__,'connect',$args);
  37. }
  38. }