Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Yii Framework 2 redis extension Change Log
2.0.18 under development
------------------------

- no changes in this release.
- Bug #247: `Cache::getValue()` now returns `false` in case of missing key (rhertogh)


2.0.17 January 11, 2022
Expand Down
10 changes: 10 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ if you want to upgrade from version A to version C and there is
version B between A and C, you need to follow the instructions
for both A and B.

Upgrade from 2.0.17
------------------

* The `Cache::getValue()` method now adheres to the specifications and returns `false` in case of a missing
(or expired) key. This might have impact in the following scenarios:
* You specified a custom `Cache::$serializer`, depending on the serializer used `Cache::get()` might now
return `false` instead of `null` in case of a missing (or expired) key.
* You extended the `Cache` class, are using the protected method `Cache::getValue()` directly and expect
a return value of `null` in case of a missing (or expired) key.

Upgrade from 2.0.13
------------------

Expand Down
7 changes: 6 additions & 1 deletion src/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ public function exists($key)
*/
protected function getValue($key)
{
return $this->getReplica()->executeCommand('GET', [$key]);
$value = $this->getReplica()->executeCommand('GET', [$key]);
if ($value === null) {
return false; // Key is not in the cache or expired
}

return $value;
}

/**
Expand Down