Problems on increment, decrement & touch
I was adding a Redis driver when I spotted this:
$object being returned from
function get($keyword, $option = array()) {
if($this->is_driver == true) {
$object = $this->driver_get($keyword,$option);
} else {
$object = $this->driver->driver_get($keyword,$option);
}
if($object == null) {
return null;
}
return $object['value'];
}
is not the entire array and only the 'value' so:
function increment($keyword, $step = 1 , $option = array()) {
$object = $this->get($keyword);
if($object == null) {
return false;
} else {
$value = (Int)$object['value'] + (Int)$step;
$time = $object['expired_time'] - @date("U");
$this->set($keyword,$value, $time, $option);
return true;
}
}
function decrement($keyword, $step = 1 , $option = array()) {
$object = $this->get($keyword);
if($object == null) {
return false;
} else {
$value = (Int)$object['value'] - (Int)$step;
$time = $object['expired_time'] - @date("U");
$this->set($keyword,$value, $time, $option);
return true;
}
}
function touch($keyword, $time = 300, $option = array()) {
$object = $this->get($keyword);
if($object == null) {
return false;
} else {
$value = $object['value'];
$time = $object['expired_time'] - @date("U") + $time;
$this->set($keyword, $value,$time, $option);
return true;
}
}
will not work and will also mess up the cached values.
I'm fixing it by passing an option to the get method so it returns the entire array.
Will send a Pull request for both this issue and the Redis driver once resolved and tested.
I will take a look it when I get home after work. Thanks. Also, if you fix it and tested , you can send me a request.
@n-i-m-a do you have driver for Reddis? because right now on current version we dont have reddis.php , if you have it, put it on this branch.
Thanks.
I'm doing some final clean-up and tests with it. will send a pull request when done but would be best if someone else would also test it out before merging.
@n-i-m-a : after you send a pull request and update the driver Reddis.php I will do a test on it right away, since version 2.2 will be release next week, I will merge your Reddis.php driver and put ur name as contribute on next version.
Thanks, bro
I'll keep you updated on that + have sent an email to discuss some matters on handling the dependencies for redis.
Will close this issue as it has been solved already.