Exemplo n.º 1
0
 /**
  * Returns an instance of the distributed cache driver
  * 
  * @return Pfw_Cache|null instance of a Pfw_Cache object or null if none
  * is configured
  */
 public static function getInstance()
 {
     if (!is_null(self::$instance)) {
         return self::$instance;
     }
     if (null == ($dist_cache = Pfw_Config::get('dist_cache'))) {
         return null;
     }
     if (is_array($dist_cache)) {
         $class = $dist_cache['class'];
         unset($dist_cache['class']);
         $options = $dist_cache;
     } else {
         $class = $dist_cache;
         $options = array();
     }
     Pfw_Loader::loadClass($class);
     self::$instance = new $class($options);
     return self::$instance;
 }
Exemplo n.º 2
0
 public function destroy($id)
 {
     if (isset($this->sessions[$id])) {
         unset($this->sessions[$id]);
     }
     Pfw_Cache_Dist::delete($this->cacheKey($id));
     $this->db->deleteFromTable($this->db_table, array('session_id = %s', $id));
 }
Exemplo n.º 3
0
 public function testOptions()
 {
     Pfw_Config::setConfig(array('dist_cache' => array('class' => 'Pfw_Cache_Stub', 'stuff' => 'ok')));
     $this->assertEquals(array('stuff' => 'ok'), Pfw_Cache_Dist::getInstance()->options);
 }