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


PHP cache::get方法代码示例

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


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

示例1: create_pm_header

function create_pm_header()
{
    global $mod, $config;
    if ($config['cache']['enabled'] && ($header = cache::get('pm_unread_' . $mod['id'])) != false) {
        if ($header === true) {
            return false;
        }
        return $header;
    }
    $query = prepare("SELECT `id` FROM ``pms`` WHERE `to` = :id AND `unread` = 1");
    $query->bindValue(':id', $mod['id'], PDO::PARAM_INT);
    $query->execute() or error(db_error($query));
    if ($pm = $query->fetch(PDO::FETCH_ASSOC)) {
        $header = array('id' => $pm['id'], 'waiting' => $query->rowCount() - 1);
    } else {
        $header = true;
    }
    if ($config['cache']['enabled']) {
        cache::set('pm_unread_' . $mod['id'], $header);
    }
    if ($header === true) {
        return false;
    }
    return $header;
}
开发者ID:odilitime,项目名称:infinity,代码行数:25,代码来源:auth.php

示例2: get_id64

function get_id64($player_id)
{
    global $db, $settings;
    if (!is_id64($player_id)) {
        $url = sprintf("http://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/?key=%s&vanityurl=%s", $settings['api_key'], $player_id);
    } else {
        return $player_id;
    }
    // Try the easy way
    $i = $db->query_first("SELECT id64 FROM tf2_players WHERE custom_url = %s", array($player_id));
    if ($i['id64']) {
        return $i['id64'];
    }
    require_once 'classes/cache.php';
    $json_string = cache::get($url);
    try {
        $rgResult = json_decode($json_string, true);
        $rgResponse = $rgResult['response'];
    } catch (Exception $e) {
        // Bad XML data. Purge and throw an error
        cache::purge($url);
        $bad_xml = true;
        return false;
        //echo "BAD XML!!!: ".$url;
    }
    if ($rgResponse['success'] == k_EResultOK) {
        $id64 = $rgResponse['steamid'];
        // Update this in the db
        $db->query("UPDATE tf2_players SET custom_url=%s WHERE id64=%s", array($player_id, $id64));
    }
    return $id64;
}
开发者ID:mwilchez,项目名称:master,代码行数:32,代码来源:functions.php

示例3: hitfailcacheitem

 function hitfailcacheitem()
 {
     try {
         $r = cache::get('bar');
     } catch (CacheException $e) {
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:7,代码来源:memcached.php

示例4: preload_stats

 function preload_stats($multi = false)
 {
     global $settings;
     $url = sprintf('http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=440&key=%s&steamid=%s', $settings['api_key'], $this->id64);
     $stats_json = cache::get($url, false, $multi);
     if ($stats_json) {
         $this->multi_stats($stats_json);
     } else {
         cache::register_multi_url($url, array($this, 'multi_stats'));
     }
 }
开发者ID:mwilchez,项目名称:master,代码行数:11,代码来源:player.php

示例5: init

 private static function init()
 {
     if (self::$keys == '') {
         if (!(self::$keys = cache::get('global-settings'))) {
             $sql = 'SELECT SQL_CACHE r_id id, r_section_id section, r_key name, r_value value, r_description description FROM <<register>>;';
             self::$keys = db::q($sql, records);
             if (db::issetError()) {
                 die;
             }
             // Записываем в кэш
             cache::set('global-settings', self::$keys);
         }
     }
 }
开发者ID:sunfun,项目名称:Bagira.CMS,代码行数:14,代码来源:reg.php

示例6: useResultCache

 public function useResultCache($timeout = 30, $params = null)
 {
     $cachekey = 'TinyORM-' . md5($this->sql);
     if ($params) {
         $cachekey .= md5(serialize($params));
     }
     $cached = cache::get($cachekey);
     if ($cached === false) {
         $query = $this->connection->prepare($this->sql);
         $query->execute($params);
         $cached = $query->fetchAll();
         cache::set($cachekey, $cached, $timeout);
     }
     return $cached;
 }
开发者ID:cagataygurturk,项目名称:tinyorm,代码行数:15,代码来源:Query.php

示例7: _accessToken

 private function _accessToken()
 {
     require_once 'class.cacheFile.php';
     $cache = new cache();
     $access_token = $cache->get('access_token');
     if ($access_token === NULL) {
         $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . APPID . "&secret=" . AppSecrect;
         $status = $this->_httpRequest($url);
         $status = json_decode($status, true);
         //将对象转为数组
         $access_token = $status['access_token'];
         $cache->set('access_token', $access_token, 7200);
     }
     return $access_token;
 }
开发者ID:tangyouyou,项目名称:WeiXin,代码行数:15,代码来源:class.weixin.php

示例8: get_group_list

 public function get_group_list()
 {
     global $_M;
     if (!$this->grouplist[$this->lang]) {
         $this->grouplist[$this->lang] = cache::get("user/grouplist_{$this->lang}");
         if (!$this->grouplist[$this->lang]) {
             $query = "SELECT * FROM {$_M['table']['user_group']} WHERE lang='{$this->lang}' order by access ASC";
             $result = DB::query($query);
             while ($list = DB::fetch_array($result)) {
                 $this->grouplist[$this->lang][$list['id']] = $list;
             }
             cache::put("user/grouplist_{$this->lang}", $this->grouplist[$this->lang]);
         }
     }
     return $this->grouplist[$this->lang];
 }
开发者ID:nanfs,项目名称:lt,代码行数:16,代码来源:group.class.php

示例9: init

    /**
     * Initializing i18n
     *
     * @param array $options
     */
    public static function init($options = [])
    {
        do {
            self::$language_code = $options['language_code'];
            $where = " AND lc_translation_language_code = '{$options['language_code']}'";
            // retrive data from cache
            $cache_id_file = $cache_id = 'numbers_backend_i18n_basic_base_' . $options['language_code'];
            // if we are including js translations
            if (strpos($_SERVER['REQUEST_URI'] ?? '', $cache_id_file . '.js') !== false) {
                $where .= " AND lc_translation_javascript = 1";
                $cache_id .= '_js';
            }
            $cache = new cache();
            $data = $cache->get($cache_id);
            if ($data !== false) {
                self::$data = !empty($data) ? $data : ['ids' => [], 'hashes' => []];
                break;
            }
            // load data from database
            $sql = <<<TTT
\t\t\t\tSELECT
\t\t\t\t\tlc_translation_id id,
\t\t\t\t\tlc_translation_text_sys sys,
\t\t\t\t\tlc_translation_text_new new
\t\t\t\tFROM lc_translations
\t\t\t\tWHERE 1=1
\t\t\t\t\t{$where}
TTT;
            $query_result = factory::model('numbers_backend_i18n_basic_model_translations')->db_object->query($sql);
            foreach ($query_result['rows'] as $k => $v) {
                if (strlen($v['sys']) > 40) {
                    $v['sys'] = sha1($v['sys']);
                }
                self::$data['hashes'][$v['sys']] = $v['new'];
                self::$data['ids'][$v['id']] = $v['sys'];
            }
            // set the cache
            $cache->set($cache_id, self::$data, ['translations']);
        } while (0);
        // load js
        numbers_frontend_media_libraries_jssha_base::add();
        layout::add_js('/numbers/media_submodules/numbers_backend_i18n_basic_media_js_i18n.js', 5001);
        layout::add_js('/numbers/backend/i18n/basic/controller/javascript/_js/' . $cache_id_file . '.js', 50000);
        // load data into cache
        return ['success' => 1, 'error' => []];
    }
开发者ID:volodymyr-volynets,项目名称:backend,代码行数:51,代码来源:base.php

示例10: tweets

function tweets($username, $params = array())
{
    $defaults = array('limit' => 10, 'cache' => true, 'refresh' => 60 * 20);
    // add the username to the defaults array
    $defaults['username'] = $username;
    $options = array_merge($defaults, $params);
    // check the cache dir
    $cacheDir = c::get('root.cache') . '/tweets';
    dir::make($cacheDir);
    // disable the cache if adding the cache dir failed
    if (!is_dir($cacheDir) || !is_writable($cacheDir)) {
        $options['cache'] = false;
    }
    // sanitize the limit
    if ($options['limit'] > 200) {
        $options['limit'] = 200;
    }
    // generate a unique cache ID
    $cacheID = 'tweets/tweets.' . md5($options['username']) . '.' . $options['limit'] . '.php';
    if ($options['cache']) {
        $cache = cache::modified($cacheID) < time() - $options['refresh'] ? false : cache::get($cacheID);
    } else {
        $cache = false;
    }
    if (!empty($cache)) {
        return $cache;
    }
    $url = 'http://api.twitter.com/1/statuses/user_timeline.json?screen_name=' . $options['username'] . '&count=' . $options['limit'];
    $json = @file_get_contents($url);
    $data = str::parse($json);
    if (!$data) {
        return false;
    }
    $result = array();
    foreach ($data as $tweet) {
        $user = $tweet['user'];
        $result[] = new tweet(array('url' => 'http://twitter.com/' . $options['username'] . '/status/' . $tweet['id_str'], 'text' => $tweet['text'], 'date' => strtotime($tweet['created_at']), 'source' => $tweet['source'], 'user' => new obj(array('name' => $user['name'], 'bio' => $user['description'], 'username' => $user['screen_name'], 'url' => 'http://twitter.com/' . $user['screen_name'], 'image' => 'http://twitter.com/api/users/profile_image/' . $user['screen_name'], 'following' => $user['friends_count'], 'followers' => $user['followers_count']))));
    }
    $result = new obj($result);
    if ($options['cache']) {
        cache::set($cacheID, $result);
    }
    return $result;
}
开发者ID:nilshendriks,项目名称:kirbycms-extensions,代码行数:44,代码来源:tweets.php

示例11: init

 static function init()
 {
     if (isset($_SESSION['curUser']['name']) && $_SESSION['curUser']['name'] != 'none') {
         self::$isGuest = false;
         self::$isAdmin = $_SESSION['curUser']['isAdmin'];
         $key = 'user' . $_SESSION['curUser']['id'];
         if (!(self::$obj = cache::get($key))) {
             self::$obj = ormObjects::get($_SESSION['curUser']['id']);
             // Записываем в кэш
             cache::set($key, self::$obj);
         }
         /*
                     self::$obj->last_visit = date('Y-m-d H:i:s');
                     self::$obj->last_ip = $_SERVER['REMOTE_ADDR'];
         
                     self::$obj->save();    */
         //проверяем наличие кукисов если есть авторизуем
     } else {
         if (isset($_COOKIE['remember_me']) && $_COOKIE['remember_me'] != '') {
             //разбиваем строку по параметрам: 0 - id, 1 - browser hash, 2 - random hash
             $params = explode('-', $_COOKIE["remember_me"]);
             $user = ormObjects::get($params[0], 'user');
             $confirmIP = strpos($user->last_ip, self::getIP(2)) === false;
             if (!$confirmIP && $params[1] == self::browserHash() && $params[2] == $user->remember_me) {
                 self::$obj = $user;
                 self::getRights();
                 self::$isAdmin = count(self::$right) == 0 ? false : true;
                 self::$isGuest = false;
                 self::updateSession($user->id, $user->login, $user->name, $user->email);
                 self::$obj->last_visit = date('Y-m-d H:i:s');
                 self::$obj->last_ip = self::getIP();
                 self::$obj->error_passw = 0;
                 self::$obj->save();
                 system::log(lang::get('ENTER_USER_WITH_COOKIE'), info);
             }
         }
     }
     if (!isset($_SESSION['curUser']['name'])) {
         self::guestCreate();
     }
 }
开发者ID:sunfun,项目名称:Bagira.CMS,代码行数:41,代码来源:user.php

示例12: get

 /**
  * Get information
  *
  * @param string $ip
  * @return array
  */
 public function get($ip)
 {
     $ip = $ip . '';
     // try to get IP information from cache
     $cache = new cache('db');
     $cache_id = 'misc_ip_ipinfo_' . $ip;
     $data = $cache->get($cache_id);
     if ($data !== false) {
         return ['success' => true, 'error' => [], 'data' => $data];
     }
     // if we need to query ipinfo.io
     $json = file_get_contents("http://ipinfo.io/{$ip}/json");
     $data = json_decode($json, true);
     if (isset($data['country'])) {
         $temp = explode(',', $data['loc']);
         $save = ['ip' => $ip, 'date' => format::now('date'), 'country' => $data['country'], 'region' => $data['region'], 'city' => $data['city'], 'postal' => $data['postal'], 'lat' => format::read_floatval($temp[0]), 'lon' => format::read_floatval($temp[1])];
         $cache->set($cache_id, $save, ['misc_ip_ipinfo'], 604800);
         return ['success' => true, 'error' => [], 'data' => $save];
     } else {
         return ['success' => false, 'error' => ['Could not decode IP address!'], 'data' => ['ip' => $ip]];
     }
 }
开发者ID:volodymyr-volynets,项目名称:backend,代码行数:28,代码来源:base.php

示例13: mod_dashboard

function mod_dashboard()
{
    global $config, $mod;
    $args = array();
    $args['boards'] = listBoards();
    if (hasPermission($config['mod']['noticeboard'])) {
        if (!$config['cache']['enabled'] || !($args['noticeboard'] = cache::get('noticeboard_preview'))) {
            $query = prepare("SELECT ``noticeboard``.*, `username` FROM ``noticeboard`` LEFT JOIN ``mods`` ON ``mods``.`id` = `mod` ORDER BY `id` DESC LIMIT :limit");
            $query->bindValue(':limit', $config['mod']['noticeboard_dashboard'], PDO::PARAM_INT);
            $query->execute() or error(db_error($query));
            $args['noticeboard'] = $query->fetchAll(PDO::FETCH_ASSOC);
            if ($config['cache']['enabled']) {
                cache::set('noticeboard_preview', $args['noticeboard']);
            }
        }
    }
    if (!$config['cache']['enabled'] || ($args['unread_pms'] = cache::get('pm_unreadcount_' . $mod['id'])) === false) {
        $query = prepare('SELECT COUNT(*) FROM ``pms`` WHERE `to` = :id AND `unread` = 1');
        $query->bindValue(':id', $mod['id']);
        $query->execute() or error(db_error($query));
        $args['unread_pms'] = $query->fetchColumn();
        if ($config['cache']['enabled']) {
            cache::set('pm_unreadcount_' . $mod['id'], $args['unread_pms']);
        }
    }
    $query = prepare('SELECT COUNT(*) AS `total_reports` FROM ``reports``' . ($mod["type"] < GLOBALVOLUNTEER ? " WHERE board = :board" : ""));
    if ($mod['type'] < GLOBALVOLUNTEER) {
        $query->bindValue(':board', $mod['boards'][0]);
    } else {
        $query = prepare('SELECT (SELECT COUNT(id) FROM reports WHERE global = 0) AS total_reports, (SELECT COUNT(id) FROM reports WHERE global = 1) AS global_reports');
    }
    $query->execute() or error(db_error($query));
    $row = $query->fetch();
    $args['reports'] = $row['total_reports'];
    $args['global_reports'] = isset($row['global_reports']) ? $row['global_reports'] : false;
    $args['logout_token'] = make_secure_link_token('logout');
    modLog('Looked at dashboard', false);
    mod_page(_('Dashboard'), 'mod/dashboard.html', $args);
}
开发者ID:ringtech,项目名称:infinity,代码行数:39,代码来源:pages.php

示例14: __construct

 /**
  * Constructor. Loads the data from the Instagram API.
  * @param string    The access token.
  * @param integer   The number of shots that will be loaded.
  * @param boolean   Chache enabled.
  * @param integer   How many seconds until the cache expires.
  * @param string    The user-id of the user or 'self' for your own account.
  */
 function __construct($_token = '', $_count = 10, $_cache = true, $_cache_expire = 3600, $_user = 'self')
 {
     // Init
     $this->images = array();
     $this->user = new stdClass();
     // Check if a token is provided
     if (trim($_token) != '') {
         // Construct the API url…
         // http://instagr.am/developer/endpoints/users/
         $url = "https://api.instagram.com/v1/users/{$_user}/media/recent/?access_token={$_token}&count={$_count}";
         // Create cache directory if it doesn't exist yet
         if ($_cache) {
             dir::make(c::get('root.cache') . '/instagram');
         }
         $images_cache_id = 'instagram/images.' . md5($_token) . '.' . $_count . '.php';
         $images_cache_data = false;
         // Try to fetch data from cache
         if ($_cache) {
             $images_cache_data = cache::modified($images_cache_id) < time() - $_cache_expire ? false : cache::get($images_cache_id);
         }
         // Load data from the API if the cache expired or the cache is empty
         if (empty($images_cache_data)) {
             $data = $this->fetch_data($url);
             $photos = json_decode($data);
             // Set new data for the cache
             if ($_cache) {
                 cache::set($images_cache_id, $photos);
             }
         } else {
             $photos = $images_cache_data;
         }
         // Process the images
         for ($i = 0; $i < $_count; $i++) {
             if (isset($photos->data[$i]) && count($photos->data) > 0) {
                 // Get the user's data from the first image
                 if ($i == 0) {
                     $this->user->username = $photos->data[$i]->user->username;
                     $this->user->full_name = $photos->data[$i]->user->full_name;
                     $this->user->picture = $photos->data[$i]->user->profile_picture;
                 }
                 // create a new object for each image
                 $obj = new stdClass();
                 $obj->link = $photos->data[$i]->link;
                 $obj->comments = @$photos->data[$i]->comments->count;
                 $obj->likes = @$photos->data[$i]->likes->count;
                 $obj->created = $photos->data[$i]->created_time;
                 $obj->thumb = @$photos->data[$i]->images->thumbnail->url;
                 $obj->url = @$photos->data[$i]->images->standard_resolution->url;
                 $obj->image_lowres = @$photos->data[$i]->images->low_resolution->url;
                 $obj->filter = $photos->data[$i]->filter;
                 $obj->location = @$photos->data[$i]->location->name;
                 $obj->latitude = @$photos->data[$i]->location->latitude;
                 $obj->longitude = @$photos->data[$i]->location->longitude;
                 $obj->tags = array();
                 // attach the new object to the array
                 $this->images[$i] = $obj;
                 // Process tags
                 for ($j = 0; $j < count($photos->data[$i]->tags); $j++) {
                     $this->images[$i]->tags[$j] = $photos->data[$i]->tags[$j];
                 }
             }
         }
     } else {
         throw new Exception('$_token MUST be set!');
     }
 }
开发者ID:scheibome,项目名称:kirbycms-extensions,代码行数:74,代码来源:instagram.php

示例15: elseif

 } elseif (preg_match('/^\\/log(\\/(\\d+))?$/', $query, $match)) {
     if (!hasPermission($config['mod']['modlog'])) {
         error($config['error']['noaccess']);
     }
     $page = isset($match[2]) ? $match[2] : 1;
     $query = prepare("SELECT `mod` as `id`, `username`, `ip`, `board`, `time`, `text` FROM `modlogs` LEFT JOIN `mods` ON `mod` = `mods`.`id` ORDER BY `time` DESC LIMIT :offset, :limit");
     $query->bindValue(':limit', $config['mod']['modlog_page'], PDO::PARAM_INT);
     $query->bindValue(':offset', ($page - 1) * $config['mod']['modlog_page'], PDO::PARAM_INT);
     $query->execute() or error(db_error($query));
     if (!$query->rowCount()) {
         $body = '<p class="unimportant" style="text-align:center">(Nothing to display.)</p>';
     } else {
         $body = '<table class="modlog">' . '<tr>' . '<th>' . _('User') . '</th>' . '<th>' . _('IP address') . '</th>' . '<th>' . _('Ago') . '</th>' . '<th>' . _('Board') . '</th>' . '<th>' . _('Action') . '</th>' . '</tr>';
         while ($log = $query->fetch()) {
             $log_id = 'log_' . md5($log['text']);
             if ($config['cache']['enabled'] && ($_log = cache::get($log_id))) {
                 $log['text'] = $_log;
             } else {
                 $log['text'] = utf8tohtml($log['text']);
                 $log['text'] = preg_replace('/(\\d+\\.\\d+\\.\\d+\\.\\d+)/', '<a href="?/IP/$1">$1</a>', $log['text']);
                 if (isset($log['board'])) {
                     if (preg_match('/post #(\\d+)/', $log['text'], $match)) {
                         $post_query = prepare(sprintf("SELECT `thread` FROM `posts_%s` WHERE `id` = :id", $log['board']));
                         $post_query->bindValue(':id', $match[1], PDO::PARAM_INT);
                         $post_query->execute() or error(db_error($query));
                         if ($post = $post_query->fetch()) {
                             $log['text'] = preg_replace('/post (#(\\d+))/', 'post <a href="' . '?/' . sprintf($config['board_path'], $log['board']) . $config['dir']['res'] . ($post['thread'] ? sprintf($config['file_page'], $post['thread']) . '#' . $match[1] : sprintf($config['file_page'], $match[1])) . '">$1</a>', $log['text']);
                         } else {
                             $log['text'] = preg_replace('/post (#(\\d+))/', 'post <s>$1</s>', $log['text']);
                         }
                         if ($config['cache']['enabled']) {
开发者ID:niksfish,项目名称:Tinyboard,代码行数:31,代码来源:mod.php


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