From c86afb902c63072cebce7c62c7b2c68bd80f3959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=86=E1=85=AE=E1=86=AB=E1=84=8C=E1=85=A5=E1=86=BC?= =?UTF-8?q?=E1=84=80=E1=85=B5?= Date: Wed, 11 Mar 2020 19:01:21 +0900 Subject: [PATCH] ## [0.18.3] - 2020-03-11 ### Fixed - Fixed `RedisCache` as checking condition whether the connection is alive when getting/setting value --- CHANGELOG.md | 4 ++++ lib/Cache/RedisCache.php | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45859be..8e47eb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/lib/Cache/RedisCache.php b/lib/Cache/RedisCache.php index af05373..9ea2d0b 100644 --- a/lib/Cache/RedisCache.php +++ b/lib/Cache/RedisCache.php @@ -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) { @@ -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);