首页 > 代码库 > php+redis缓存类

php+redis缓存类

php+redis缓存类

<?php
  
class redisCache {
   /**
    * $host : redis服务器ip
    * $port : redis服务器端口
    * $lifetime : 缓存文件有效期,单位为秒
    * $cacheid : 缓存文件路径,包含文件名
   */
   private $host;
   private $port;
   private $lifetime;
   private $cacheid;
   private $data;
   public $redis;
   /**
    * 析构函数,检查缓存目录是否有效,默认赋值
   */
   function __construct($lifetime=1800) {
        //配置
        $this->host = "127.0.0.1";
        $this->port = "6379";
        $redis = new Redis(); 
        $redis->pconnect($this->host,$this->port); 
        $this->redis=$redis;
        $this->cacheid = $this->getcacheid();
        $this->lifetime = $lifetime;
        $this->data=http://www.mamicode.com/$redis->hMGet($this->cacheid, array('content','creattime'));>

php+redis缓存类