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

Commit

Permalink
## [0.18.3] - 2020-03-11
Browse files Browse the repository at this point in the history
### Fixed
- Fixed `RedisCache` as checking condition whether the connection is alive when getting/setting value
  • Loading branch information
문정기 committed Mar 11, 2020
1 parent 7b25f69 commit c86afb9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.18.3] - 2020-03-11
### Fixed
- Fixed `RedisCache` as checking condition whether the connection is alive when getting/setting value

## [0.18.2] - 2020-03-06
### Add
- Added function `removeDoubleSpace` to get rid of the spaces over one in `StringUtils`
Expand Down
4 changes: 2 additions & 2 deletions lib/Cache/RedisCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(string $host, int $port = 6379)
public function get(string $key): ?string
{
try {
if ($this->client !== null) {
if ($this->client !== null && $this->client->isConnected()) {
return $this->client->get($key);
}
} catch (\Exception $e) {
Expand All @@ -44,7 +44,7 @@ public function setJson(string $key, array $value, int $ttl): void
public function set(string $key, string $value, int $ttl): void
{
try {
if ($this->client !== null) {
if ($this->client !== null && $this->client->isConnected()) {
// setnx()은 호출 시점에서 해당하는 key-value가 존재하지 않는 경우에만 set이 성공한다.
// set 성공 시 return 1, 실패 시 return 0
$result = $this->client->setnx($key, $value);
Expand Down

0 comments on commit c86afb9

Please sign in to comment.