예제 #1
0
 public function save($data, $key, array $tags = array(), $lifeTime)
 {
     if (empty($key) || empty($data) || empty($lifeTime)) {
         return;
     }
     $tags = array_unique($tags);
     $instantLoad = false;
     $optionIndex = array_search(OW_CacheManager::TAG_OPTION_INSTANT_LOAD, $tags);
     if ($optionIndex !== false) {
         $instantLoad = true;
         unset($tags[$optionIndex]);
     }
     $expTime = time() + $lifeTime;
     $oldEntryId = $this->dbo->queryForColumn("SELECT `id` FROM `" . $this->getCacheTableName() . "` WHERE `key` = :key", array('key' => $key));
     if ($oldEntryId !== null) {
         $this->dbo->query("DELETE FROM `" . $this->getCacheTableName() . "` WHERE `id` = :id", array('id' => $oldEntryId));
         $this->dbo->query("DELETE FROM `" . $this->getTagsTableName() . "` WHERE `cacheId` = :cacheId", array('cacheId' => $oldEntryId));
     }
     $this->dbo->query("INSERT INTO `" . $this->getCacheTableName() . "` (`key`, `content`, `expireTimestamp`, `instantLoad`) VALUES (:key, :content, :ts, :il)", array('key' => $key, 'content' => $data, 'ts' => $expTime, 'il' => $instantLoad));
     if ($tags) {
         $cacheId = $this->dbo->getInsertId();
         foreach ($tags as $tag) {
             $this->dbo->query("INSERT INTO `" . $this->getTagsTableName() . "` (`tag`, `cacheId`) VALUES (:tag, :cacheId)", array('tag' => $tag, 'cacheId' => $cacheId));
         }
     }
 }
예제 #2
0
 private function setDevMode($mode = null)
 {
     $mode = $mode ? intval($mode) : 1;
     $this->db->query("UPDATE `{$this->dbPrefix}base_config` SET `value` = 1 WHERE `key` = 'base' AND `name` = 'dev_mode'", array("mode" => $mode));
 }