| 
...
 | 
...
 | 
@@ -178,7 +178,16 @@ class RedisPool { | 
| 
 | 
 | 
     public function incr($key, $ttl = null){
 | 
| 
 | 
 | 
         if($ttl){
 | 
| 
 | 
 | 
             return $this->getClient()->eval(
 | 
| 
 | 
 | 
                 "local x = redis.call('incr',KEYS[1]);redis.call('expire',KEYS[1],ARGV[1]);return x",
 | 
| 
 | 
 | 
                 "
 | 
| 
 | 
 | 
 if redis.call('exists',KEYS[1]) == 0 then
 | 
| 
 | 
 | 
 	local x = redis.call('incr',KEYS[1])
 | 
| 
 | 
 | 
 	if x then
 | 
| 
 | 
 | 
 		redis.call('expire',KEYS[1],ARGV[1])
 | 
| 
 | 
 | 
 	end
 | 
| 
 | 
 | 
 	return x
 | 
| 
 | 
 | 
 else
 | 
| 
 | 
 | 
 	return redis.call('incr',KEYS[1])
 | 
| 
 | 
 | 
 end",
 | 
| 
 | 
 | 
                 [$key, $ttl],
 | 
| 
 | 
 | 
                 1
 | 
| 
 | 
 | 
             );
 | 
| 
...
 | 
...
 | 
@@ -197,7 +206,16 @@ class RedisPool { | 
| 
 | 
 | 
     public function decr($key,$ttl = null){
 | 
| 
 | 
 | 
         if($ttl){
 | 
| 
 | 
 | 
             return $this->getClient()->eval(
 | 
| 
 | 
 | 
                 "local x = redis.call('decr',KEYS[1]);redis.call('expire',KEYS[1],ARGV[1]);return x",
 | 
| 
 | 
 | 
                 "
 | 
| 
 | 
 | 
 if redis.call('exists',KEYS[1]) == 0 then
 | 
| 
 | 
 | 
 	local x = redis.call('decr',KEYS[1])
 | 
| 
 | 
 | 
 	if x then
 | 
| 
 | 
 | 
 		redis.call('expire',KEYS[1],ARGV[1])
 | 
| 
 | 
 | 
 	end
 | 
| 
 | 
 | 
 	return x
 | 
| 
 | 
 | 
 else
 | 
| 
 | 
 | 
 	return redis.call('decr',KEYS[1])
 | 
| 
 | 
 | 
 end",
 | 
| 
 | 
 | 
                 [$key, $ttl],
 | 
| 
 | 
 | 
                 1
 | 
| 
 | 
 | 
             );
 | 
...
 | 
...
 | 
 |