当前位置: 首页>>代码示例>>PHP>>正文


PHP cache::store方法代码示例

本文整理汇总了PHP中cache::store方法的典型用法代码示例。如果您正苦于以下问题:PHP cache::store方法的具体用法?PHP cache::store怎么用?PHP cache::store使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cache的用法示例。


在下文中一共展示了cache::store方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute()
 {
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         /* Update menu
          */
         if ($this->model->menu_oke($_POST["menu"]) == false) {
             $this->show_menu_form($_POST["menu"]);
         } else {
             if ($this->model->update_menu($_POST["menu"]) == false) {
                 $this->output->add_tag("result", "Error while updating menu.");
             } else {
                 $this->output->add_tag("result", "The menu has been updated.");
                 $this->user->log_action("menu updated");
                 header("X-Hiawatha-Cache-Remove: all");
                 $cache = new cache($this->db, "menu");
                 $cache->store("last_updated", time(), 365 * DAY);
             }
         }
     } else {
         /* Show menu
          */
         if (($menu = $this->model->get_menu()) === false) {
             $this->output->add_tag("result", "Error loading menu.");
         } else {
             $this->show_menu_form($menu);
         }
     }
 }
开发者ID:shannara,项目名称:banshee,代码行数:28,代码来源:menu.php

示例2: get_facebook_cache

 /**
  * Hent Facebook-cache
  */
 protected function get_facebook_cache()
 {
     // har vi cache?
     $data = cache::fetch("facebook_posts");
     if ($data) {
         return $data;
     }
     // authentiser
     $app_id = KOF_FB_APP_ID;
     $app_secret = KOF_FB_APP_SECRET;
     if (!$app_id || !$app_secret) {
         return null;
     }
     $ret = @file_get_contents("https://graph.facebook.com/oauth/access_token?client_id={$app_id}&client_secret={$app_secret}&grant_type=client_credentials");
     if ($ret === false) {
         // kunne ikke hente data
         putlog("CREWCHAN", "Henting av Facebook-data feilet.");
         cache::store("facebook_posts", array());
     }
     $info = null;
     parse_str($ret, $info);
     // hent JSON
     $json = @file_get_contents("https://graph.facebook.com/kofradia/posts?access_token={$info['access_token']}");
     $data = json_decode($json, true);
     cache::store("facebook_posts", $data);
     return $data;
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:30,代码来源:forsiden.php

示例3: show_alert

 private function show_alert($index)
 {
     if (valid_input($index, VALIDATE_NUMBERS, VALIDATE_NONEMPTY) == false) {
         return;
     } else {
         if ($index >= count($this->alerts)) {
             return;
         }
     }
     list($title, $type, $column) = $this->alerts[(int) $index];
     $cache = new cache($this->db, "dashboard_" . $this->user->username);
     if (($list = $cache->{$column}) === NULL) {
         $function = "get_" . $type . "_statistics";
         $list = $this->model->{$function}($column);
         $cache->store($column, $list, $this->settings->dashboard_page_refresh * 60 - 1);
     }
     if ($list == false) {
         return;
     }
     $this->output->open_tag("list", array("title" => $title));
     foreach ($list as $name => $item) {
         $this->output->add_tag("item", $name, array("count" => $item["today"], "change" => $item["change"]));
     }
     $this->output->close_tag();
 }
开发者ID:Wabuo,项目名称:monitor,代码行数:25,代码来源:dashboard.php

示例4: reload

 /**
  * Load settings and save to cache
  */
 public static function reload()
 {
     $result = \Kofradia\DB::get()->query("SELECT id, name, value FROM settings");
     \game::$settings = array();
     while ($row = $result->fetch()) {
         \game::$settings[$row['name']] = array("id" => $row['id'], "value" => $row['value']);
     }
     // keep for 1 hour
     \cache::store("settings", \game::$settings, 3600);
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:13,代码来源:Settings.php

示例5: getRanks

 /**
  * Get list of ranks
  *
  * @return array(\Kofradia\Game\Rank\Base, ..)
  */
 public static function getRanks()
 {
     if (!static::$by_number) {
         // check cache first, then get from DB
         if ($cache = \cache::fetch("ranks-" . static::$type)) {
             static::$by_number = $cache;
             return $cache;
         }
         static::fetchRanks();
         \cache::store("ranks-" . static::$type, static::$by_number);
     }
     return static::$by_number;
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:18,代码来源:Base.php

示例6: get_likes_num

 /**
  * Hent antall likes
  */
 public static function get_likes_num()
 {
     $d = cache::fetch("facebook_likes");
     if ($d !== false) {
         return $d;
     }
     $ttl = 900;
     // 15 min cache
     // hent data
     $json = @file_get_contents("https://graph.facebook.com/kofradia");
     if (!$json) {
         cache::store("facebook_likes", "ukjent", $ttl);
         return "ukjent";
     }
     $data = json_decode($json, true);
     cache::store("facebook_likes", $data['likes'], $ttl);
     return $data['likes'];
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:21,代码来源:class.facebook.php

示例7: cache_load

 /**
  * Hent, evt. generer, cache
  */
 public static function cache_load($reload = false)
 {
     if (!$reload) {
         $data = cache::fetch("hall_of_fame");
         if ($data) {
             self::$data = $data;
             return;
         }
     }
     $data = self::get_data_structure();
     // hent fra databasen
     $result = \Kofradia\DB::get()->query("\n\t\t\tSELECT hof_id, hof_name, hof_sub, hof_time, hof_data\n\t\t\tFROM hall_of_fame");
     while ($row = $result->fetch()) {
         $data[$row['hof_name']][$row['hof_sub'] ?: 0] = array($row['hof_time'], unserialize($row['hof_data']));
     }
     cache::store("hall_of_fame", $data, 900);
     self::$data = $data;
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:21,代码来源:class.hall_of_fame.php

示例8: load

 /** Hent oppgaver */
 private static function load($skip_cache = false)
 {
     // forsøk å hent fra cache
     if (!$skip_cache && !self::$cache) {
         self::$cache = cache::fetch("tasks");
     }
     // hent fra databasen
     if ($skip_cache || !self::$cache) {
         global $_base;
         $result = \Kofradia\DB::get()->query("SELECT t_name, t_ant, t_last FROM tasks");
         // les data
         self::$cache = array();
         while ($row = $result->fetch()) {
             self::$cache[$row['t_name']] = $row;
         }
         // lagre til cache
         cache::store("tasks", self::$cache);
     }
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:20,代码来源:class.tasks.php

示例9: __construct

 public function __construct($db)
 {
     $this->db = $db;
     /* Handle settings updates
      */
     $cache = new cache($this->db, "settings");
     if ($cache->last_updated === null) {
         $cache->store("last_updated", time(), 365 * DAY);
     }
     if (isset($_SESSION["settings_last_updated"]) == false) {
         $_SESSION["settings_last_updated"] = $cache->last_updated;
     } else {
         if ($cache->last_updated > $_SESSION["settings_last_updated"]) {
             $_SESSION["settings_cache"] = array();
             $_SESSION["settings_last_updated"] = $cache->last_updated;
         }
     }
     unset($cache);
     if (isset($_SESSION["settings_cache"]) == false) {
         $_SESSION["settings_cache"] = array();
     }
     $this->cache =& $_SESSION["settings_cache"];
 }
开发者ID:shannara,项目名称:banshee,代码行数:23,代码来源:settings.php

示例10: store

 function store($name, $value)
 {
     if (function_exists('\\apcu_store')) {
         if (is_bool($value)) {
             \apcu_delete($name);
         } else {
             \apcu_store($name, $value);
         }
     } else {
         if (function_exists('\\apc_store')) {
             if (is_bool($value)) {
                 \apc_delete($name);
             } else {
                 \apc_store($name, $value);
             }
         } else {
             parent::store($name, $value);
         }
     }
 }
开发者ID:hazardland,项目名称:db,代码行数:20,代码来源:db.php

示例11: to_output

 public function to_output($current_url = null)
 {
     /* Handle menu updates
      */
     $cache = new cache($this->db, "menu");
     if ($cache->last_updated === null) {
         $cache->store("last_updated", time(), 365 * DAY);
     }
     if (isset($_SESSION["menu_last_updated"]) == false) {
         $_SESSION["menu_last_updated"] = $cache->last_updated;
     } else {
         if ($cache->last_updated > $_SESSION["menu_last_updated"]) {
             $_SESSION["menu_cache"] = array();
             $_SESSION["menu_last_updated"] = $cache->last_updated;
         }
     }
     unset($cache);
     /* Build menu
      */
     if (isset($_SESSION["menu_cache"]) == false) {
         $_SESSION["menu_cache"] = array();
     }
     $cache =& $_SESSION["menu_cache"];
     $username = $this->user !== null ? $this->user->username : "";
     $index = sha1(sprintf("%d-%d-%s-%s", $this->parent_id, $this->depth, $username, $current_url));
     if (isset($cache[$index]) == false) {
         if (($menu = $this->get_menu($this->parent_id, $this->depth, $current_url)) === false) {
             return false;
         }
         $cache[$index] = json_encode($menu);
     } else {
         $menu = json_decode($cache[$index], true);
     }
     $this->show_menu($menu);
     return true;
 }
开发者ID:Wabuo,项目名称:monitor,代码行数:36,代码来源:menu.php

示例12: handle_submit

 protected function handle_submit()
 {
     parent::handle_submit();
     $cache = new cache($this->db, "settings");
     $cache->store("last_updated", time(), 365 * DAY);
 }
开发者ID:shannara,项目名称:banshee,代码行数:6,代码来源:settings.php

示例13: get_revision_info

 protected static function get_revision_info()
 {
     $branch = "";
     // hent informasjon fra Git
     $data = @file_get_contents(PATH_ROOT . "/.git/HEAD");
     if (!$data) {
         return null;
     }
     if (mb_substr($data, 0, 3) == "ref") {
         $ref = trim(mb_substr($data, 5));
         $commit = @file_get_contents(PATH_ROOT . "/.git/{$ref}");
         $branch = basename($ref);
     } else {
         $commit = trim($data);
         $branch = $commit;
     }
     if (!$commit) {
         return null;
     }
     // hent tidspunkt og melding
     $last_rev = cache::fetch("gitlog_last_rev");
     $last_info = cache::fetch("gitlog_last_info");
     if (!$last_rev || $last_rev != $commit) {
         $res = shell_exec("git log -1 --format=\"%ct %s\"");
         $last_info = sscanf($res, "%d %[^\$]s");
         cache::store("gitlog_last_info", $last_info);
     }
     $r = array("branch" => $branch, "commit" => $commit, "date" => $last_info[0], "message" => $last_info[1]);
     return $r;
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:30,代码来源:default.php

示例14: array

<?php

// denne filen henter bydelene og lagrer til cache
$result = \Kofradia\DB::get()->query("SELECT * FROM bydeler ORDER BY name");
game::$bydeler = array();
while ($row = $result->fetch()) {
    game::$bydeler[$row['id']] = $row;
}
// lagre til cache
cache::store("bydeler", game::$bydeler, 0);
开发者ID:Kuzat,项目名称:kofradia,代码行数:10,代码来源:update_db_bydeler.php

示例15: update_cache

 /**
  * Bygg opp cache over auksjoner for menyen
  */
 public static function update_cache()
 {
     // hent alle aktive og kommende auksjoner
     $result = \Kofradia\DB::get()->query("SELECT a_start, a_end FROM auksjoner WHERE a_end >= " . time() . " AND a_active != 0 AND a_completed = 0");
     $data = array();
     while ($row = $result->fetch(\PDO::FETCH_NUM)) {
         $data[] = $row;
     }
     cache::store("auksjoner_active", $data);
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:13,代码来源:class.auksjon.php


注:本文中的cache::store方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。