add phpredis in redis subrepo

This commit is contained in:
Guobao Jiang 2014-03-12 15:40:56 +08:00
parent 196cb23f65
commit 5f8e254eb2
2 changed files with 109 additions and 1 deletions

View File

@ -28,5 +28,5 @@ TRIBPATH="/home/vagrant/sw/redis-3.0.0-beta1/src"
SLAVES=$(cat slaves.node |grep -v '#')
## boot redis-cluster using redis-trib.rb
# ${TRIBPATH}/redis-trib.rb create --replicas 1 ${SLAVES}
${TRIBPATH}/redis-trib.rb create --replicas 1 ${SLAVES}
echo $SLAVES

108
redis/phpredis/iredis.php Normal file
View File

@ -0,0 +1,108 @@
<?php
/***
* INTRO:
* This class provides an interface to redis.
*
* VERSION
* 2014-02-27 1.0
* 2014-03-12 1.1 add extension_loaded if possible
*
* NOTE
* You should install phpredis first from
* https://code.google.com/p/phpredis/ or
* https://github.com/nicolasff/phpredis
*
* AUTHOR:
* Aborn Jiang
*
***/
class iredis
{
private $redis;
private $redis_server = '127.0.0.1';
private $redis_port = '6379';
public function __construct()
{
if (!extension_loaded('redis')) {
##echo "no load!";
if (!dl('redis.so')) {
exit;
}
}
$this->redis = new redis();
$this->redis->connect($this->redis_server, $this->redis_port);
## $this->redis->pconnect($this->redis_server, $this->redis_port);
}
public function __destruct()
{
$this->redis->close();
}
public function configure($redis_server, $redis_port)
{
$this->redis_server = $redis_server;
$this->redis_port = $redis_port;
}
public function set($key, $value)
{
return $this->redis->set($key,$value);
}
public function get($key)
{
return $this->redis->get($key);
}
public function release($key)
{
return $this->redis->delete($key);
}
public function close()
{
$this->redis->close();
}
public function select($database=0)
{
$this->redis->select($database);
}
public function append($key, $value)
{
return $this->redis->append($key, $value);
}
public function hset($key, $keysub, $value)
{
return $this->redis->hSet($key, $keysub, $value);
}
public function expire($key, $time)
{ ## set expire timeout with $time (second).
return $this->redis->setTimeout($key, $time);
}
public function del($key)
{
return $this->redis->delete($key);
}
public function delete($key)
{
return $this->redis->delete($key);
}
public function hgetall($key)
{
return $this->redis->hGetAll($key);
}
}
?>