コード例 #1
0
 /**
  * Get meta description of the table and generate fields array
  * @return array
  */
 public function getMetadata()
 {
     if ($this->table && !$this->fields) {
         $runtime_cache = new waRuntimeCache('db/' . $this->table);
         if ($this->fields = $runtime_cache->get()) {
             return $this->fields;
         }
         if (SystemConfig::isDebug()) {
             $this->fields = $this->getFields();
         } else {
             $cache = new waSystemCache('db/' . $this->table);
             if (!($this->fields = $cache->get())) {
                 $this->fields = $this->getFields();
                 $cache->set($this->fields);
             }
         }
         $runtime_cache->set($this->fields);
     }
     return $this->fields;
 }
コード例 #2
0
 public function getCurrencies($codes = null)
 {
     $runtime_cache = new waRuntimeCache('shop_currencies');
     if ($runtime_cache->isCached()) {
         $data = $runtime_cache->get();
     } else {
         $data = array();
         if ($cache = wa('shop')->getCache()) {
             $data = $cache->get('currencies');
         }
         if (!$data) {
             $data = array();
             $primary = $this->getPrimaryCurrency();
             $currencies = waCurrency::getAll(true);
             foreach ($this->query("SELECT * FROM " . $this->table . " ORDER BY sort") as $c) {
                 $code = $c['code'];
                 if (isset($currencies[$code])) {
                     $c['rate'] = (double) $c['rate'];
                     $data[$code] = $currencies[$code] + $c;
                     $data[$code]['is_primary'] = $primary == $code;
                 }
             }
             if (!empty($cache)) {
                 $cache->set('currencies', $data, 86400);
             }
         }
         $runtime_cache->set($data);
     }
     if ($codes) {
         $result = array();
         foreach ((array) $codes as $code) {
             if (isset($data[$code])) {
                 $result[$code] = $data[$code];
             }
         }
         return $result;
     } else {
         return $data;
     }
 }
コード例 #3
0
 public function getAuth()
 {
     $cache = new waRuntimeCache('wa-config/auth');
     if ($cache->isCached()) {
         return $cache->get();
     } else {
         $data = $this->getConfigFile('auth');
         $cache->set($data);
         return $data;
     }
 }