From 140ebc73e502ac458e040d09a0c6f1d57d91f4cd Mon Sep 17 00:00:00 2001 From: vaughanbrittonsage Date: Thu, 25 Jan 2018 14:07:57 +0000 Subject: [PATCH 1/2] resolved bug caused by empty strings during set/get preventing hydration block from executing --- cache_store_redis/lib/cache_store_redis.rb | 4 ++-- cache_store_redis/lib/cache_store_redis/version.rb | 2 +- cache_store_redis/spec/cache_store_redis_spec.rb | 7 ++----- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/cache_store_redis/lib/cache_store_redis.rb b/cache_store_redis/lib/cache_store_redis.rb index ff82743..e46829f 100644 --- a/cache_store_redis/lib/cache_store_redis.rb +++ b/cache_store_redis/lib/cache_store_redis.rb @@ -116,7 +116,7 @@ def with_client def set(key, value, expires_in = 0) k = build_key(key) - v = if value.nil? + v = if value.nil? || (value.is_a?(String) && value.empty?) nil else serialize(value) @@ -147,7 +147,7 @@ def get(key, expires_in = 0, &block) end if !value.nil? && value.delete('\"').strip.empty? - value = value.delete('\"') + value = nil else value = deserialize(value) unless value.nil? end diff --git a/cache_store_redis/lib/cache_store_redis/version.rb b/cache_store_redis/lib/cache_store_redis/version.rb index 75a4f3e..eb373ae 100644 --- a/cache_store_redis/lib/cache_store_redis/version.rb +++ b/cache_store_redis/lib/cache_store_redis/version.rb @@ -1,3 +1,3 @@ module CacheStoreRedis - VERSION = '0.5.2' + VERSION = '0.5.3' end diff --git a/cache_store_redis/spec/cache_store_redis_spec.rb b/cache_store_redis/spec/cache_store_redis_spec.rb index 21f3da1..d067d28 100644 --- a/cache_store_redis/spec/cache_store_redis_spec.rb +++ b/cache_store_redis/spec/cache_store_redis_spec.rb @@ -119,12 +119,9 @@ class TestObject let(:value) { '' } it 'does not attempt to deserialize' do - v = @cache_store.get(key) do - value - end - + @cache_store.set(key, value) expect(subject).to_not receive(:deserialize) - expect(@cache_store.get(key)).to eq v + expect(@cache_store.get(key)).to be nil end end end From 191051bec819e742c4c3dcfcad670481f4ddaea8 Mon Sep 17 00:00:00 2001 From: vaughanbrittonsage Date: Thu, 25 Jan 2018 14:14:49 +0000 Subject: [PATCH 2/2] added strip as per PR comments --- cache_store_redis/lib/cache_store_redis.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cache_store_redis/lib/cache_store_redis.rb b/cache_store_redis/lib/cache_store_redis.rb index e46829f..97c544c 100644 --- a/cache_store_redis/lib/cache_store_redis.rb +++ b/cache_store_redis/lib/cache_store_redis.rb @@ -116,7 +116,7 @@ def with_client def set(key, value, expires_in = 0) k = build_key(key) - v = if value.nil? || (value.is_a?(String) && value.empty?) + v = if value.nil? || (value.is_a?(String) && value.strip.empty?) nil else serialize(value)