示例#1
0
 public function testNotFoundCache()
 {
     $this->assertFalse(Cache::get('testfalse'));
 }
示例#2
0
 private function loaddata($force = false)
 {
     if (!isset($this->data[$this->primary_key]) || $this->dontfetch) {
         return false;
     }
     $cachekey = $this->getCacheKey($this->data[$this->primary_key]);
     if ($this->isCacheable() && !$force) {
         $cached = Cache::get($cachekey);
         if ($cached !== false) {
             $this->data = $cached;
             $this->fetched = true;
             $this->fetchedfromcache = true;
             return true;
         }
     }
     $query = "SELECT * FROM " . $this->table . " WHERE 1 AND ";
     $query .= " `" . $this->primary_key . "`=?";
     $params = array($this->data[$this->primary_key]);
     $query .= " limit 1";
     $fetched_data = Database::query($query)->execute($params)->fetchOne();
     if ($fetched_data) {
         $this->data = $fetched_data;
         $this->fetched = true;
         Cache::set($cachekey, $this->data, $this->cache_timeout);
         return true;
     } else {
         return false;
     }
 }