Exemple #1
0
 public static function create()
 {
     if (self::$instance === null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Exemple #2
0
 public static function create($backend = "")
 {
     if (empty($backend) && empty(self::$defaultBackend)) {
         $message = __METHOD__ . "() must specify the backend.";
         throw new Sabel_Exception_Runtime($message);
     }
     if ((ENVIRONMENT & PRODUCTION) < 1) {
         return Sabel_Cache_Null::create();
     }
     if (empty($backend)) {
         $backend = self::$defaultBackend;
     }
     switch ($backend) {
         case "file":
             $storage = Sabel_Cache_File::create(CACHE_DIR_PATH . DS . "data");
             break;
         case "apc":
             $storage = Sabel_Cache_Apc::create();
             break;
         case "memcache":
             $storage = Sabel_Cache_Memcache::create();
             // $storage->addServer(/* $host, $port = 11211, $weight = 1 */);
             break;
         default:
             $message = __METHOD__ . "() invalid cache backend.";
             throw new Sabel_Exception_Runtime($message);
     }
     return $storage;
 }
Exemple #3
0
 public static function getUsableCache()
 {
     self::init();
     $instance = null;
     if (!defined("ENVIRONMENT") || ENVIRONMENT !== PRODUCTION) {
         $instance = Sabel_Cache_Null::create();
     } elseif (self::$support["apc"]) {
         $instance = Sabel_Cache_Apc::create();
     } elseif (self::$support["memcache"]) {
         $instance = Sabel_Cache_Memcache::create();
     } else {
         $instance = Sabel_Cache_File::create();
     }
     return $instance;
 }
Exemple #4
0
 public function setUp()
 {
     $this->cache = Sabel_Cache_Null::create();
 }