Example #1
0
 function find($type = 'all', $params = array())
 {
     $cached = false;
     parent::initializeFind($type, $params);
     if (!empty($this->cache) and !empty($params['cache']) and Base::getConfig('cache') >= 1 and Base::getConfig('cache_query') >= 1) {
         $cache = Cache::getInstance($this->tablename . '.queries', array('expiration' => Base::getConfig('query_cache_expiry', 3600)));
         $data = $cache->get($type . '.' . md5(serialize($params)));
         if (!empty($data)) {
             $cached = true;
         }
     }
     if (empty($data)) {
         $data = parent::find($type, $params);
     }
     if (!empty($this->cache) and !empty($params['cache']) and !$cached and Base::getConfig('cache') >= 1 and Base::getConfig('cache_query') >= 1) {
         $cache = Cache::getInstance($this->tablename . '.queries', array('expiration' => Base::getConfig('query_cache_expiry', 3600)));
         $cache->set($type . '.' . md5(serialize($params)), $data);
     }
     return $data;
 }