Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
hotfix #40 - small cs fixes and CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-mabe committed Nov 6, 2015
1 parent a9668fc commit 3bd741b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ All notable changes to this project will be documented in this file, in reverse

### Fixed

- Nothing.
- [#40](https://github.com/zendframework/zend-cache/pull/40)
Fixed TTL support of `Redis::addItem`

## 2.5.3 - 2015-09-15

Expand Down
4 changes: 3 additions & 1 deletion src/Storage/Adapter/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,14 @@ protected function internalSetItems(array & $normalizedKeyValuePairs)
protected function internalAddItem(& $normalizedKey, & $value)
{
$redis = $this->getRedisResource();
$ttl = $this->getOptions()->getTtl();
$ttl = $this->getOptions()->getTtl();

try {
if ($ttl) {
if ($this->resourceManager->getMajorVersion($this->resourceId) < 2) {
throw new Exception\UnsupportedMethodCallException("To use ttl you need version >= 2.0.0");
}

/**
* To ensure expected behaviour, we stick with the "setnx" method.
* This means we only set the ttl after the key/value has been successfully set.
Expand All @@ -311,6 +312,7 @@ protected function internalAddItem(& $normalizedKey, & $value)
} else {
$success = $redis->setnx($this->namespacePrefix . $normalizedKey, $value);
}

return $success;
} catch (RedisResourceException $e) {
throw new Exception\RuntimeException($redis->getLastError(), $e->getCode(), $e);
Expand Down

0 comments on commit 3bd741b

Please sign in to comment.