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


PHP cache::instance方法代码示例

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


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

示例1: getUserInfo2

 public function getUserInfo2($uin)
 {
     $keyTpl = 's_tframework_debug_cache_key_%s';
     $key = sprintf($keyTpl, $uin);
     $errmsg = null;
     try {
         $cacheData = cache::instance('rs1')->get($key);
         if ($cacheData) {
             echo "\r\n <br /> use redis! \r\n <br /> ";
             return unserialize($cacheData);
         }
         //$data =  $this->queryFetch('desc ent_package;');
         //第二种调用得到 ORM 的方式!可以得到任意 db 和table 的orm 实例
         $data = modelorm::instance($this->_dbAlias)->table($this->_table)->where('package_id > 5')->getOne();
         if ($data) {
             $expire = 16;
             echo "\r\n <br /> set redis! \r\n <br /> ";
             cache::instance('rs1')->set($key, serialize($data), $expire);
         }
     } catch (exception_mysqlpdo $e) {
         $code = $e->getCode();
         $errmsg = $e->getMessage();
         switch ($code) {
             case exception_mysqlpdo::type_conf_error:
                 //config error, you can do something here
                 break;
             case exception_mysqlpdo::type_high_risk_query:
                 // high risk of your query, may effect the hole table
                 break;
             case exception_mysqlpdo::type_query_error:
                 //query failed or some ...
                 break;
             default:
                 break;
         }
     } catch (exception_db $e) {
         $code = $e->getCode();
         $errmsg = $e->getMessage();
     } catch (exception_cache $e) {
         $code = $e->getCode();
         $errmsg = $e->getMessage();
     } catch (Exception $e) {
         throw $e;
     }
     if ($errmsg) {
         //do something to record the exception error message
         return false;
     }
     return $data;
 }
开发者ID:hiloy,项目名称:autophp,代码行数:50,代码来源:demo.php

示例2: getInstance

 public static function getInstance()
 {
     if (self::$instance === null) {
         $list = array('XCache_provider', 'MemCache_provider', 'APC_provider', 'DBA_DB4_provider', 'DBA_FlatFile_provider', 'FileCache_provider');
         if (defined('MCMS_CACHE_PROVIDER') and class_exists(MCMS_CACHE_PROVIDER)) {
             array_unshift($list, MCMS_CACHE_PROVIDER);
         }
         foreach ($list as $class) {
             if (null !== (self::$instance = call_user_func(array($class, 'initialize')))) {
                 break;
             }
         }
     }
     return self::$instance;
 }
开发者ID:umonkey,项目名称:molinos-cms,代码行数:15,代码来源:class.cache.php

示例3: tpl_set_var

 tpl_set_var('difficulty_options', $difficulty_options);
 //terrain
 $terrain = isset($_POST['terrain']) ? $_POST['terrain'] : 1;
 $terrain_options = '<option value="1">' . $sel_message . '</option>';
 for ($i = 2; $i <= 10; $i++) {
     if ($terrain == $i) {
         $terrain_options .= '<option value="' . $i . '" selected="selected">' . $i / 2 . '</option>';
     } else {
         $terrain_options .= '<option value="' . $i . '">' . $i / 2 . '</option>';
     }
     $terrain_options .= "\n";
 }
 tpl_set_var('terrain_options', $terrain_options);
 tpl_set_var('sizeoptions', common::buildCacheSizeSelector($sel_type, $sel_size));
 //typeoptions
 $cache = cache::instance();
 $cacheTypes = $cache->getCacheTypes();
 $types = '<option value="-1">' . tr('select_one') . '</option>';
 foreach ($cacheTypes as $typeId => $type) {
     /* block creating forbidden cache types */
     if (in_array($typeId, $config['forbidenCacheTypes'])) {
         continue;
     }
     /* apply cache limit by type per user */
     if (isset($config['cacheLimitByTypePerUser'][$typeId]) && $cacheLimitByTypePerUser[$typeId] >= $config['cacheLimitByTypePerUser'][$typeId]) {
         continue;
     }
     if ($typeId == $sel_type) {
         $types .= '<option value="' . $typeId . '" selected="selected">' . tr($type['translation']) . '</option>';
     } else {
         $types .= '<option value="' . $typeId . '">' . tr($type['translation']) . '</option>';
开发者ID:pawelzielak,项目名称:opencaching-pl,代码行数:31,代码来源:newcache.php

示例4: fopen

require_once $rootpath . 'lib/consts.inc.php';
/* take datetime format from settings.inc.php */
$sDateformat = $datetimeFormat;
// Check if another instance of the script is running
$lock_file = fopen("/tmp/notification-run_notify.lock", "w");
if (!flock($lock_file, LOCK_EX | LOCK_NB)) {
    // Another instance of the script is running - exit
    echo "Another instance of run_notify.php is currently running.\nExiting.\n";
    fclose($lock_file);
    exit;
}
// No other instance - do normal processing
$db = new dataBase();
$rsNotifyQuery = " SELECT  `notify_waiting`.`id`, `notify_waiting`.`cache_id`, `notify_waiting`.`type`,\n                `user`.`username`, user.user_id as cache_owner_id,\n                user.hidden_count as hidden, user.notfounds_count as dnf, user.founds_count as found,\n                `user2`.`email`, `user2`.`username` as `recpname`, `user2`.`latitude` as `lat1`, `user2`.`longitude` as `lon1`, `user2`.`user_id` as `recid`,\n                `caches`.`name` as `cachename`, `caches`.`date_hidden`, `caches`.`latitude` as `lat2`, `caches`.`longitude` as `lon2`, `caches`.`wp_oc`,\n                `caches`.`type` as `cachetype`,\n                `caches`.`size` as `cachesize`\n            FROM `notify_waiting`, `caches`, `user`, `user` `user2`\n            WHERE `notify_waiting`.`cache_id`=`caches`.`cache_id`\n              AND `notify_waiting`.`user_id`=`user2`.`user_id`\n              AND `caches`.`user_id`=`user`.`user_id`\n              AND `notify_waiting`.`id` > :1\n            ORDER BY `notify_waiting`.`id`\n            LIMIT 0,100\n";
/* init caches container */
$cacheCntainer = cache::instance();
$cacheTypes = $cacheCntainer->getCacheTypes();
$cacheSizes = $cacheCntainer->getCacheSizes();
$cacheTypeIcons = $cacheCntainer->getCacheTypeIcons();
$id = 0;
do {
    $db->multiVariableQuery($rsNotifyQuery, $id);
    $rsNotify = $db->dbResultFetchAll();
    foreach ($rsNotify as $rNotify) {
        $id = $rNotify['id'];
        /* send out everything that has to be sent */
        if (process_new_cache($rNotify) == 0) {
            $db->multiVariableQuery("DELETE FROM `notify_waiting` WHERE `id` =:1", $rNotify['id']);
        }
    }
    if (count($rsNotify) > 0) {
开发者ID:pawelzielak,项目名称:opencaching-pl,代码行数:31,代码来源:run_notify.php

示例5: cache

 /**
  * 缓存
  *
  * @param $config array  数据库参数
  * @return object 数据库连接
  */
 public static function cache($name, $value = '', $expire = 0)
 {
     static $caches = array();
     if (isset($caches[$name]) && empty($value)) {
         return $caches[$name];
     }
     if (is_array($name) or is_bool($name)) {
         return cache::instance($name);
     }
     $cache = cache::instance();
     // $name === null 时清空全部缓存
     if ($name === null) {
         $cache->clear();
     }
     // $value === null 时清空全部缓存
     if ($value === null) {
         unset($caches[$name]);
         $cache->delete($name);
     }
     // 返回指定缓存
     if (empty($value)) {
         $value = $cache->get($name);
         $caches[$name] = $value;
         return $value;
     }
     //设置缓存
     return $cache->set($name, $value, $expire);
 }
开发者ID:dalinhuang,项目名称:zotop,代码行数:34,代码来源:zotop.php

示例6: __construct

 /**
  * @param array $params
  *            'cacheId' => (integer) database cache identifier
  *            'wpId' => (string) geoCache wayPoint (ex. OP21F4)
  */
 public function __construct(array $params = array())
 {
     if (isset($params['cacheId'])) {
         // load from DB if cachId param is set
         $db = OcDb::instance();
         $this->id = (int) $params['cacheId'];
         $queryById = "SELECT size, status, founds, notfounds, topratings, votes, notes, score,  name, type, date_hidden, longitude, latitude, wp_oc, wp_gc, wp_nc, wp_tc, wp_ge, user_id, last_found, difficulty, terrain, way_length, logpw, search_time, date_created, watcher, ignorer_count, org_user_id, desc_languages, mp3count, picturescount, date_activate FROM `caches` WHERE `cache_id`=:1 LIMIT 1";
         $s = $db->multiVariableQuery($queryById, $this->id);
         $cacheDbRow = $db->dbResultFetch($s);
         if (is_array($cacheDbRow)) {
             $this->loadFromRow($cacheDbRow);
         } else {
             ddd('geocache not found in db? TODO: cache-not-found handling');
             //TODO: cache-not-found handling?
         }
         $this->loadCacheLocation($db);
     } else {
         if (isset($params['okapiRow'])) {
             $this->loadFromOkapiRow($params['okapiRow']);
         }
     }
     $this->dictionary = \cache::instance();
 }
开发者ID:kojoty,项目名称:opencaching-pl,代码行数:28,代码来源:GeoCache.php

示例7: get_cache

 /**
  * Cache get item
  *
  * @param   string		the id of the cache item
  * @return  mixed		the cache item data or false
  */
 public function get_cache($id)
 {
     if (!$this->_config['cache']) {
         return false;
     }
     return cache::instance()->get($id);
 }
开发者ID:rjd22,项目名称:Kohana-CMS-Library,代码行数:13,代码来源:cms.php

示例8: buildCacheSizeSelector

 public static function buildCacheSizeSelector($sel_type, $sel_size)
 {
     $cache = cache::instance();
     $cacheSizes = $cache->getCacheSizes();
     $sizes = '<option value="-1">' . tr('select_one') . '</option>';
     foreach ($cacheSizes as $size) {
         if ($sel_type == 6) {
             if ($size['id'] == cache::SIZE_NOCONTAINER) {
                 $sizes .= '<option value="' . $size['id'] . '" selected="selected">' . tr($size['translation']) . '</option>';
                 tpl_set_var('is_disabled_size', '');
             } else {
                 $sizes .= '<option value="' . $size['id'] . '">' . tr($size['translation']) . '</option>';
                 tpl_set_var('is_disabled_size', 'disabled');
             }
         } elseif ($size['id'] != cache::SIZE_NOCONTAINER) {
             if ($size['id'] == $sel_size) {
                 $sizes .= '<option value="' . $size['id'] . '" selected="selected">' . tr($size['translation']) . '</option>';
             } else {
                 $sizes .= '<option value="' . $size['id'] . '">' . tr($size['translation']) . '</option>';
             }
         }
     }
     return $sizes;
 }
开发者ID:pawelzielak,项目名称:opencaching-pl,代码行数:24,代码来源:common.inc.php


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