Example #1
0
 public function getCache($r)
 {
     $tpl = new Dase_Template($r);
     $cache = Dase_Cache::get($this->config);
     $cache->setData('my_cache_file', 'hello world cached');
     $data = $cache->getData('my_cache_file');
     $ip = $_SERVER['SERVER_ADDR'];
     $r->renderResponse('cached data: ' . $data . " ({$ip})");
 }
Example #2
0
 function testDataIsCached()
 {
     $c = new Dase_Config(BASE_PATH);
     $c->load('inc/config.php');
     $c->load('inc/local_config.php');
     $cache = Dase_Cache::get($c);
     $cache->setData('my_cache_file', 'hello world');
     $data = $cache->getData('my_cache_file');
     $this->assertTrue('hello world' == $data);
 }
Example #3
0
 public static function initGlobalData($db, $config)
 {
     $cache = Dase_Cache::get($config);
     //refreshed once per hour -- expunge when necessary!
     $serialized_app_data = $cache->getData('app_data', 3600);
     if (!$serialized_app_data) {
         $c = new Dase_DBO_Collection($db);
         $colls = array();
         $acl = array();
         foreach ($c->find() as $coll) {
             $colls[$coll->ascii_id] = $coll->collection_name;
             $acl[$coll->ascii_id] = $coll->visibility;
             //compat
             $acl[$coll->ascii_id . '_collection'] = $coll->visibility;
         }
         $app_data['collections'] = $colls;
         $app_data['media_acl'] = $acl;
         $cache->setData('app_data', serialize($app_data));
     } else {
         $app_data = unserialize($serialized_app_data);
     }
     return $app_data;
 }
Example #4
0
 public function initCache()
 {
     $this->cache = Dase_Cache::get($this->config);
 }