Exemplo n.º 1
0
 public static function getDefaultCacheDriver()
 {
     if (self::$defaultDriver === null) {
         // Cache to APC by default if available, if not - cache to the tmp directory
         if (\Stash\Driver\Apc::isAvailable()) {
             $driver = new \Stash\Driver\Apc();
         } else {
             $driver = new \Stash\Driver\FileSystem();
         }
         self::$defaultDriver = $driver;
     }
     return self::$defaultDriver;
 }
Exemplo n.º 2
0
 public function getCachePool()
 {
     if (!isset($this->cachePool)) {
         // Cache to APC by default if available, if not - cache to the tmp directory
         if (\Stash\Driver\Apc::isAvailable()) {
             $driver = new \Stash\Driver\Apc();
         } else {
             $driver = new \Stash\Driver\FileSystem();
         }
         $this->cachePool = new \Stash\Pool($driver);
     }
     return $this->cachePool;
 }
Exemplo n.º 3
0
 /**
  * Initialise the Cache class
  *
  */
 protected function init()
 {
     if (Apc::isAvailable()) {
         $driver = new Apc();
     } else {
         if (!is_dir(WT_DATA_DIR . DIRECTORY_SEPARATOR . 'cache')) {
             // We may not have permission - especially during setup, before we instruct
             // the user to "chmod 777 /data"
             @mkdir(WT_DATA_DIR . DIRECTORY_SEPARATOR . 'cache');
         }
         if (is_dir(WT_DATA_DIR . DIRECTORY_SEPARATOR . 'cache')) {
             $driver = new FileSystem(array('path' => WT_DATA_DIR . DIRECTORY_SEPARATOR . 'cache'));
         } else {
             // No cache available, let's just use a basic one :-(
             $driver = new Ephemeral();
         }
     }
     $this->cache = new \Stash\Pool($driver);
     $this->is_init = true;
 }