• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP getCache函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中getCache函数的典型用法代码示例。如果您正苦于以下问题:PHP getCache函数的具体用法?PHP getCache怎么用?PHP getCache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: DeleteComment

 public static function DeleteComment($id)
 {
     try {
         $safeId = ensureInt($id);
     } catch (Exception $e) {
         throw new Exception('删除评论时出错:' . $e->getMessage());
         return null;
     }
     $commentInfo = self::GetCommentInfo($id);
     $cacheKey = 'postcomment_' . $commentPost['comment_post`'];
     $cache = getCache($cacheKey);
     if ($commentInfo && $cache) {
         while (list($key, $value) = each($cache)) {
             if ($value['comment_id'] == $safeId) {
                 unset($cache[$key]);
                 break;
             }
         }
         setCache($cacheKey, $cache);
     }
     $cacheKey = 'commentinfo_' . $safeId;
     setCache($cacheKey, null);
     $sql = "delete from wa_comment where comment_id = {$safeId} limit 1";
     $ret = runSql($sql);
     if (!$ret) {
         throw new Exception('删除评论时出错。');
         return null;
     }
     return $ret;
 }
开发者ID:bdbai,项目名称:wawall-sae,代码行数:30,代码来源:wa-comment.php


示例2: mysql_query_cache

function mysql_query_cache($sql, $linkIdentifier = false, $timeout = 4)
{
    $mysqli = $GLOBALS['mysqli'];
    //首先调用上面的getCache函数,如果返回值不为false的话,就说明是从memcached服务器获取的数据
    //如果返回false,此时就需要直接从数据库中获取数据了。
    //需要注意的是这里使用操作的命令加上sql语句的md5码作为一个特定的key,可能大家觉得使用数据项的
    //名称作为key会比较自然一点。运行memcached加上"-vv"参数,并且不作为daemon运行的话,可以看见
    //memcached处理时输出的相关信息
    if (!($cache = getCache(md5("mysql_query" . $sql)))) {
        $cache = false;
        $r = mysqli_query($mysqli, $sql);
        $fields = mysqli_fetch_fields($r);
        //读取数据库,并将结果放入$cache数组中
        for ($i = 0; $row = mysqli_fetch_array($r); $i++) {
            $j = 0;
            foreach ($fields as $val) {
                $cache[$i][$val->name] = $row[$j];
                $j++;
            }
        }
        //将数据放入memcached服务器中,如果memcached服务器没有开的话,此语句什么也不会做
        //如果开启了服务器的话,数据将会被缓存到memcached服务器中
        if (!setCache(md5("mysql_query" . $sql), $cache, $timeout)) {
            # If we get here, there isn’t a memcache daemon running or responding
            echo "apt-get install memcached";
        }
    }
    return $cache;
}
开发者ID:RX78NY1,项目名称:hustoj,代码行数:29,代码来源:memcache.php


示例3: mysql_query_cache

function mysql_query_cache($sql, $linkIdentifier = false, $timeout = MEMCACHE_STATICDATA_TIMEOUT, $goSilent = true)
{
    global $memCache;
    if (is_null($memCache)) {
        mc_open();
    }
    if (($cache = getCache(md5("mysql_query" . $sql))) === false) {
        if (!$goSilent) {
            dprintf("mysql_query_cache(): using MySQL data.", $sql);
        }
        $cache = false;
        $r = $linkIdentifier !== false ? mysql_query($sql, $linkIdentifier) : mysql_query($sql);
        if (is_resource($r) && ($rows = mysql_num_rows($r)) !== 0) {
            while ($row = mysql_fetch_assoc($r)) {
                $results[] = $row;
            }
            $cache = serialize($results);
            if (!setCache(md5("mysql_query" . $sql), $cache, $timeout)) {
                # If we get here, there isn't a memcache daemon running or responding
                if (!$goSilent) {
                    dprintf("mysql_query_cache(): failed to update memcached");
                }
            }
            mysql_free_result($r);
        }
    } else {
        if (!$goSilent) {
            dprintf("mysql_query_cache(): using memcached data.");
        }
    }
    return unserialize($cache);
}
开发者ID:SpeedProg,项目名称:wormhol.es,代码行数:32,代码来源:funcs.php


示例4: _initialize

  /**
   * 前期执行
   */
  public function _initialize(){
	//配置
	$configs = getCache('Config:list');
	$this->configs = $configs;
	$this->assign('configs',$configs);
    //dump($configs);exit;
	//购物车
	/*
	$shopcart=  session('shopcart');
	$this->shopcartnum = count($shopcart);
	$this->assign('shopcartnum', count($shopcart));
	*/
	//上级
	if($_GET['r']){
	  cookie('r',$_GET['r']);
	}
	//会员信息
	$member_msg = session('member_msg');
	$user = unserialize(authcode($member_msg,'DECODE'));
    $user['id'] = 107;//模拟用户

	if($user){
	  if($user['openid'] && !$user['id']){
		$to_url = C('MEMBER_SITE_URL').'/Member/message';
	    header("location:".$to_url);exit;
	  }
	  $model = D('Member');
	  $data['a.id'] = $user['id'];
	  $db_pre = C('DB_PREFIX');
	  $user = $model->alias('a')->join('`'.$db_pre.'member_wallet` as b on a.id=b.member_id')->join('`'.$db_pre.'member_msg` as c on a.id=c.member_id')->field('a.id,a.pid,a.nickname,logo,lv,lv_name,email,utype,username,realname,mobile,password,salt,pv_id,ct_id,province,city,create_time,last_login_time,balance,frozen,c.sex')->where($data)->find();
	  //echo $model->getlastsql();exit;
	  if($user['balance']==null){
		$data['update_time'] = time();
		$model->add($data);
	    $user['balance'] = 0;
		$user['frozen'] = 0;
		$user['update_time'] = time();
	  }
	  //dump($user);
	  $user['username'] = $user['username'] ? $user['username'] : $user['mobile'];
	  $this->user = $user;
	  $this->assign('user',$user);
	}
	$this->iswx = isWeixin();//是否微信浏览器
	$this->login_url = C('SITE_URL').'/index.php/Public/login';
	$this->register_url = C('SITE_URL').'/index.php/Public/register';
	if(!IS_AJAX){
		if($_SERVER['QUERY_STRING']){
		  $from_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
		}else{
		  $from_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];	
		}
		$from_url_except = array('login','register','reg_do','verify','checkLogin','check_username','check_email','get_city');
		if(array_search(ACTION_NAME,$from_url_except)===false && CONTROLLER_NAME!='Public'){
		  $_SESSION['self_url'] = $from_url;
		}	
	}
	
	$this->assign('self_url',$_SESSION['self_url']);
  }
开发者ID:8yong8,项目名称:vshop,代码行数:63,代码来源:BaseController.class.php


示例5: testServices

 public function testServices()
 {
     $ins = getAuth();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Auth\IAuth::class, $ins);
     $ins = getView();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\View\IView::class, $ins);
     $ins = getLog();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Log\ILog::class, $ins);
     //        $ins = getDB();
     //        $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Database\MedooDB::class, $ins);
     //        $ins = getRedis();
     //        $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Database\PRedis::class, $ins);
     //        $ins = getDataPool();
     //        $this->assertInstanceOf(\Wwtg99\DataPool\Common\IDataPool::class, $ins);
     $ins = getCache();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Storage\Cache::class, $ins);
     $ins = getSession();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Storage\SessionUtil::class, $ins);
     $ins = getCookie();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Storage\CookieUtil::class, $ins);
     $ins = getOValue();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Storage\OldValue::class, $ins);
     $ins = getAssets();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\View\AssetsManager::class, $ins);
     $ins = getMailer();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Utils\Mail::class, $ins);
     $ins = Flight::Express();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Utils\Express::class, $ins);
     $ins = getPlugin('php');
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Plugin\IPlugin::class, $ins);
 }
开发者ID:wwtg99,项目名称:flight2wwu,代码行数:31,代码来源:ComponentTester.php


示例6: mysql_query_cache

function mysql_query_cache($sql, $linkIdentifier = false, $timeout = 4)
{
    //首先调用上面的getCache函数,如果返回值不为false的话,就说明是从memcached服务器获取的数据
    //如果返回false,此时就需要直接从数据库中获取数据了。
    //需要注意的是这里使用操作的命令加上sql语句的md5码作为一个特定的key,可能大家觉得使用数据项的
    //名称作为key会比较自然一点。运行memcached加上"-vv"参数,并且不作为daemon运行的话,可以看见
    //memcached处理时输出的相关信息
    if (!($cache = getCache(md5("mysql_query" . $sql)))) {
        $cache = false;
        $r = $linkIdentifier != false ? mysql_query($sql, $linkIdentifier) : mysql_query($sql);
        //读取数据库,并将结果放入$cache数组中
        if (is_resource($r) && ($rows = mysql_num_rows($r)) != 0) {
            for ($i = 0; $i < $rows; $i++) {
                $fields = mysql_num_fields($r);
                $row = mysql_fetch_array($r);
                for ($j = 0; $j < $fields; $j++) {
                    if ($i == 0) {
                        $columns[$j] = mysql_field_name($r, $j);
                    }
                    $cache[$i][$columns[$j]] = $row[$j];
                }
            }
            //将数据放入memcached服务器中,如果memcached服务器没有开的话,此语句什么也不会做
            //如果开启了服务器的话,数据将会被缓存到memcached服务器中
            if (!setCache(md5("mysql_query" . $sql), $cache, $timeout)) {
                # If we get here, there isn’t a memcache daemon running or responding
            }
        }
    }
    return $cache;
}
开发者ID:siriushr,项目名称:hustoj,代码行数:31,代码来源:memcache.php


示例7: generateCache

function generateCache($file, $content)
{
    $cache_file = getCache($file);
    $dir = dirname($cache_file);
    mkdir($dir, 0777, true);
    file_put_contents($cache_file, $content);
    touchCache($file);
}
开发者ID:juijs,项目名称:store.jui.io,代码行数:8,代码来源:common.php


示例8: run

    public function run()
    {
        global $_FANWE;
        $root = array();
        $root['return'] = 1;
        $key = 'm/sharecate';
        $cache_list = getCache($key);
        if ($cache_list !== NULL || TIME_UTC - $cache_list['cache_time'] > 600) {
            $cate_list = array();
            $min_time = $this->getQuarterMinTime();
            $max_time = getTodayTime();
            FanweService::instance()->cache->loadCache('albums');
            $album_cate = $_FANWE['cache']['albums']['category'];
            foreach ($album_cate as $k => $v) {
                $cate = array();
                $cate['cate_id'] = $v['id'];
                $cate['cate_name'] = $v['name'];
                $cate['short_name'] = $v['name'];
                $cate['cate_code'] = $v['cate_code'];
                $cate['cate_icon'] = FS("Image")->getImageUrl($v['img'], 2);
                $cate['desc'] = $v['desc'];
                $cate['create_time'] = $v['create_time'];
                //获取本季分享数量
                $share_count_sql = 'select count(DISTINCT s.share_id) from ' . FDB::table("share") . ' as s 
					INNER JOIN ' . FDB::table("album_share") . ' as al on s.share_id = al.share_id where al.cid = ' . $v['id'] . " and s.day_time >= {$min_time} AND s.day_time <= {$max_time} ";
                $cate['share_count'] = FDB::resultFirst($share_count_sql);
                $cate['img_tags'] = array();
                $img_size = 320;
                $sql = 'select s.share_id,al.title,sp.img from ' . FDB::table("share") . ' as s
					INNER JOIN ' . FDB::table("album_share") . ' as als ON s.share_id = als.share_id 
					INNER JOIN ' . FDB::table("album") . ' as al ON als.album_id = al.id
					INNER JOIN ' . FDB::table("share_photo") . " as sp ON s.share_id = sp.share_id \r\n\t\t\t\t\tWHERE s.day_time >= {$min_time} AND s.day_time <= {$max_time} AND als.cid = " . $v['id'] . " GROUP BY s.share_id ORDER BY s.share_id desc limit 5";
                $res = FDB::query($sql);
                while ($data = FDB::fetch($res)) {
                    $img_data = array();
                    $img_data['share_id'] = $data['share_id'];
                    $img_data['tag_name'] = $data['title'];
                    $img_data['is_tag'] = 0;
                    $img_data['img'] = FS("Image")->getImageUrl(getImgName($data['img'], $img_size, $img_size, 1, true), 2);
                    $img_data['url_tag'] = urlencode($data['title']);
                    $cate['img_tags'][] = $img_data;
                    $img_size = 160;
                }
                $cate['txt_tags'] = array();
                $cate_list[] = $cate;
            }
            $cache_list = array();
            $cache_list['cate_list'] = $cate_list;
            $cache_list['cache_time'] = TIME_UTC;
            setCache($key, $cache_list);
        } else {
            $cate_list = $cache_list['cate_list'];
        }
        $root['item'] = $cate_list;
        m_display($root);
    }
开发者ID:BGCX261,项目名称:zhubao-tupu-svn-to-git,代码行数:56,代码来源:sharecate.mapi.php


示例9: _initialize

  public function _initialize(){
	if($_GET['sign']!=C('sign')){
	  echo 'fail';exit;
	}
	//配置
	$configs = getCache('Config:list');
	$this->configs = $configs;
	//公用函数
	include_once C('PUBLIC_INCLUDE')."function.inc.php";
  }
开发者ID:8yong8,项目名称:vshop,代码行数:10,代码来源:TimingController.class.php


示例10: __construct

 public function __construct($params)
 {
     parent::__construct();
     $this->db = EpiDatabase::getInstance('mysql', $params['database'], $params['host'], $params['username'], $params['password']);
     $this->table = $params['table'];
     if (isset($params['cacheMask']) && $params['cacheMask']) {
         $this->cacheMask = $params['cacheMask'];
         $this->cacheObj = getCache();
     }
 }
开发者ID:gg1977,项目名称:frontend,代码行数:10,代码来源:EpiConfig_MySql.php


示例11: verifyCSRFCode

 /**
  * @param $code
  * @return bool
  */
 public function verifyCSRFCode($code)
 {
     if ($code) {
         $v = getCache()->get($code);
         if ($v === 1) {
             return true;
         }
     }
     return false;
 }
开发者ID:wwtg99,项目名称:flight2wwu,代码行数:14,代码来源:CSRFCode.php


示例12: MyMethod

 public static function MyMethod()
 {
     if (isset($_GET['name'])) {
         getCache()->set('name', $_GET['name']);
     }
     $name = getCache()->get('name');
     if (empty($name)) {
         $name = '[Enter your name]';
     }
     echo '<h1>Hello ' . $name . '</h1><p><form><input type="text" size="30" name="name"><br><input type="submit" value="Enter your name"></form></p>';
 }
开发者ID:Jpsstack,项目名称:epiphany,代码行数:11,代码来源:index.php


示例13: m_express

function m_express($content)
{
    global $_FANWE;
    $express = getCache('m_emotion_express_cache');
    //缓存过的表情hash
    if (!$express) {
        $express_rs = FDB::fetchAll("select `emotion`,concat('" . $_FANWE['site_url'] . "public/expression/',`type`,'/',`filename`) as fname from " . FDB::table('expression'));
        foreach ($express_rs as $k => $row) {
            $express[0][] = $row['emotion'];
            $express[1][] = "<img src='" . $row['fname'] . "' title='" . preg_replace("/[\\[\\]]/", '', $row['emotion']) . "' />";
        }
        setCache('m_emotion_express_cache', $express);
    }
    $content = str_replace($express[0], $express[1], $content);
    $parse_user = array();
    preg_match_all("/@([^\f\n\r\t\v@<> ]{2,20}?)(?:\\:| )/", $content, $users);
    if (!empty($users[1])) {
        $patterns = array();
        $replace = array();
        $users = array_unique($users[1]);
        $arr = array();
        foreach ($users as $user) {
            if (!empty($user)) {
                $arr[] = addslashes($user);
            }
        }
        $res = FDB::query('SELECT uid,user_name
			FROM ' . FDB::table('user') . '
			WHERE user_name ' . FDB::createIN($arr));
        while ($data = FDB::fetch($res)) {
            $parse_user[$data['user_name']] = $data['uid'];
        }
    }
    $parse_events = array();
    preg_match_all("/#([^\f\n\r\t\v]{1,80}?)#/", $content, $events);
    if (!empty($events[1])) {
        $patterns = array();
        $replace = array();
        $events = array_unique($events[1]);
        $arr = array();
        foreach ($events as $event) {
            if (!empty($event)) {
                $arr[] = addslashes($event);
            }
        }
        $res = FDB::query('SELECT id,title
			FROM ' . FDB::table('event') . '
			WHERE title ' . FDB::createIN($arr));
        while ($data = FDB::fetch($res)) {
            $parse_events[$data['title']] = $data['id'];
        }
    }
    return array("users" => $parse_user, "events" => $parse_events);
}
开发者ID:BGCX261,项目名称:zhubao-tupu-svn-to-git,代码行数:54,代码来源:base.mapi.php


示例14: keywords

 function keywords()
 {
     $cacheName = 'c_keywords';
     $cache = getCache($cacheName);
     if ($cache) {
         return unserialize($cache);
     } else {
         $keywords = $this->select();
         setCache($cacheName, serialize($keywords));
         return $keywords;
     }
 }
开发者ID:liuguogen,项目名称:weixin,代码行数:12,代码来源:keywords_model.class.php


示例15: getCompany

 public function getCompany($token)
 {
     $token = htmlspecialchars($token, ENT_QUOTES);
     $crt = getCache('company_' . $token);
     if (0 && $crt) {
         return unserialize($crt);
     } else {
         $ps = $this->get_one(array('token' => $token, 'isbranch' => 0));
         setCache('company_' . $token, serialize($ps));
         return $ps;
     }
 }
开发者ID:liuguogen,项目名称:weixin,代码行数:12,代码来源:company_model.class.php


示例16: getChannelsByParentID

 function getChannelsByParentID($parentid, $output = 'OBJECT')
 {
     $parentid = intval($parentid);
     $crt = getCache('channelsOf' . $parentid . 'o' . $output);
     if ($crt) {
         return unserialize($crt);
     } else {
         $channels = $this->get_results('*', '', 'parentid=' . $parentid, 'taxis ASC');
         setZendCache(serialize($channels), 'channelsOf' . $parentid . 'o' . $output);
         return $channels;
     }
 }
开发者ID:liuguogen,项目名称:weixin,代码行数:12,代码来源:channel_model.class.php


示例17: getSiteByToken

 function getSiteByToken($token)
 {
     $cacheName = 'siteByToken' . $token;
     $cache = getCache($cacheName);
     if ($cache) {
         return unserialize($cache);
     } else {
         $site = $this->get_one(array('token' => $token));
         setCache($cacheName, serialize($site));
         return $site;
     }
 }
开发者ID:ailingsen,项目名称:pigcms,代码行数:12,代码来源:site_model.class.php


示例18: getContentsByChannel

 public function getContentsByChannel($channelid)
 {
     $channelid = intval($channelid);
     $crt = getCache('c_contentsOf' . $channelid);
     if ($crt & $channelid) {
         return unserialize($crt);
     } else {
         $contents = $this->select(array('channel_id' => $channelid), '*', '0,30', 'taxis DESC');
         setZendCache(serialize($contents), 'c_contentsOf' . $channelid);
         return $contents;
     }
 }
开发者ID:liuguogen,项目名称:weixin,代码行数:12,代码来源:article_model.class.php


示例19: getContentPictures

 public function getContentPictures($id)
 {
     $id = intval($id);
     $crt = getCache('contentPictures' . $id);
     if ($crt) {
         return unserialize($crt);
     } else {
         $ps = $this->get_results('*', '', array('contentid' => $id), 'taxis ASC');
         setCache('contentPictures' . $id, serialize($ps));
         return $ps;
     }
 }
开发者ID:ailingsen,项目名称:pigcms,代码行数:12,代码来源:picture_model.class.php


示例20: verifyCaptcha

 /**
  * @param string $phrase
  * @return bool
  */
 public function verifyCaptcha($phrase)
 {
     if ($phrase) {
         $ip = Request::get()->getRequest()->ip;
         $key = md5($phrase . $ip);
         $v = getCache()->get($key);
         $b = CaptchaBuilder::create($v);
         if ($b->testPhrase($phrase)) {
             return true;
         }
     }
     return false;
 }
开发者ID:wwtg99,项目名称:flight2wwu,代码行数:17,代码来源:Captcha.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP getCacheName函数代码示例发布时间:2022-05-15
下一篇:
PHP getCSetting函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap