You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
879 B
46 lines
879 B
<?php
|
|
|
|
namespace redis;
|
|
|
|
class Redis
|
|
{
|
|
private $host = '127.0.0.1';
|
|
private $port = '6379';
|
|
private $select = 6;
|
|
private $redis = '';
|
|
public function __construct($prefix)
|
|
{
|
|
$this->redis = new \Redis();
|
|
$this->redis->connect($this->host,$this->port);
|
|
$this->redis->select($this->select);
|
|
$this->redis->setOption(\Redis::OPT_PREFIX,$prefix);
|
|
|
|
}
|
|
|
|
/**
|
|
* redis set
|
|
* @param $key
|
|
* @param $value
|
|
* @param int $timeout
|
|
*/
|
|
public function set($key,$value,$timeout = 0){
|
|
return $this->redis->set($key,$value,$timeout);
|
|
}
|
|
|
|
/**
|
|
* redis get
|
|
* @param $key
|
|
*/
|
|
public function get($key){
|
|
return $this->redis->get($key);
|
|
}
|
|
|
|
/**
|
|
* redis del
|
|
* @param $key
|
|
*/
|
|
public function del($key){
|
|
return $this->redis->del($key);
|
|
}
|
|
|
|
} |