没有合适的资源?快使用搜索试试~ 我知道了~
php操作redis缓存方法分享
0 下载量 71 浏览量
2020-12-18
13:48:56
上传
评论
收藏 43KB PDF 举报
温馨提示
试读
3页
php redis缓存操作 <?php /** * Redis缓存操作 * @author hxm * @version 1.0 * @since 2015.05.04 */ class RCache extends Object implements CacheFace { private $redis = null; //redis对象 private $sId = 1; //servier服务ID private $con = null;//链接资源 /** * 初始化Redis * * @return Object */ p
资源推荐
资源详情
资源评论
php操作操作redis缓存方法分享缓存方法分享
php redis缓存操作
<?php
/**
* Redis缓存操作
* @author hxm
* @version 1.0
* @since 2015.05.04
*/
class RCache extends Object implements CacheFace
{
private $redis = null; //redis对象
private $sId = 1; //servier服务ID
private $con = null;//链接资源
/**
* 初始化Redis
*
* @return Object
*/
public function __construct()
{
if ( !class_exists('Redis') )
{
throw new QException('PHP extension does not exist: Redis');
}
$this->redis = new Redis();
}
/**
* 链接memcahce服务
*
* @access private
* @param string $key 关键字
* @param string $value 缓存内容
* @return array
*/
private function connect( $sid )
{
$file = $this->CacheFile();
require $file;
if(! isset($cache) )
{
throw new QException('缓存配置文件不存在'.$file);
}
$server = $cache[$this->cacheId];
$sid = isset($sid) == 0 ? $this->sId : $sid;//memcache服务选择
if ( ! $server[$sid])
{
throw new QException('当前操作的缓存服务器配置文件不存在');
}
$host = $server[$sid]['host'];
$port = $server[$sid]['port'];
try {
$this->redis->connect( $host , $port );
} catch (Exception $e) {
exit('memecache连接失败,错误信息:'. $e->getMessage());
}
}
/**
* 写入缓存
*
* @access private
* @param string $key 关键字
资源评论
weixin_38684335
- 粉丝: 1
- 资源: 932
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功