-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stefano Azzolini
committed
Jul 1, 2016
1 parent
2c8a3f4
commit 278cd92
Showing
2 changed files
with
9 additions
and
15 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,10 @@ | |
* Core\Cache Redis Driver. | ||
* | ||
* @package core | ||
* @author [email protected] | ||
* @version 1.0 | ||
* @copyright Caffeina srl - 2014 - http://caffeina.co | ||
* @author [email protected] | ||
* @author [email protected] | ||
* @version 1.0.1 | ||
* @copyright Caffeina srl - 2014-2016 - http://caffeina.com | ||
*/ | ||
|
||
|
||
|
@@ -43,7 +44,7 @@ public function __construct($opt=[]){ | |
* https://github.com/nrk/predis | ||
*/ | ||
$this->options = array_merge($opt,$this->options); | ||
$this->redis = new \Predis\Client($this->options['scheme'].'://'.$this->options['host'].':'.$this->options['port'].'/',[ | ||
$this->redis = new \Predis\Client($this->options['scheme'].'://'.$this->options['host'].':'.$this->options['port'].'/', [ | ||
'prefix' => 'core:'.$this->options['prefix'], | ||
'exceptions' => $this->options['exceptions'], | ||
'connection_timeout' => $this->options['timeout'], | ||
|
@@ -57,7 +58,7 @@ public function get($key){ | |
} | ||
|
||
public function set($key,$value,$expire=0){ | ||
$expire ? $this->redis->setex($key,$expire,serialize($value)) : $this->redis->set($key,serialize($value)); | ||
return $expire >= 0 ? $this->redis->setex($key,$expire,serialize($value)) : $this->redis->set($key,serialize($value)); | ||
} | ||
|
||
public function delete($key){ | ||
|
@@ -69,8 +70,9 @@ public function exists($key){ | |
} | ||
|
||
public function flush(){ | ||
if (empty($this->redis->keys('*'))) return false; | ||
return call_user_func_array([$this->redis,'eval'], ["return redis.call('del', unpack(redis.call('keys', ARGV[1])))", "0", "*"]); | ||
return $this->redis->keys('*') | ||
? $this->redis->eval("return redis.call('del', unpack(redis.call('keys', ARGV[1])))", "0", "*") | ||
: false; | ||
} | ||
|
||
public function inc($key,$value=1){ | ||
|