Skip to content

Commit

Permalink
Respect config duration parameter by using setTimeout for increment &…
Browse files Browse the repository at this point in the history
… decrement.
  • Loading branch information
florianbrede-ayet authored and markstory committed Jun 20, 2017
1 parent 7f24155 commit d389b14
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Cache/Engine/RedisEngine.php
Expand Up @@ -173,9 +173,14 @@ public function read($key)
*/
public function increment($key, $offset = 1)
{
$duration = $this->_config['duration'];
$key = $this->_key($key);

return (int)$this->_Redis->incrBy($key, $offset);
$value = (int)$this->_Redis->incrBy($key, $offset);

$this->_Redis->setTimeout($key, $duration);

return $value;
}

/**
Expand All @@ -187,9 +192,14 @@ public function increment($key, $offset = 1)
*/
public function decrement($key, $offset = 1)
{
$duration = $this->_config['duration'];
$key = $this->_key($key);

return (int)$this->_Redis->decrBy($key, $offset);
$value = (int)$this->_Redis->decrBy($key, $offset);

$this->_Redis->setTimeout($key, $duration);

return $value;
}

/**
Expand Down

0 comments on commit d389b14

Please sign in to comment.