From 6b027837bb97b2192096818b428fc4854ff31609 Mon Sep 17 00:00:00 2001 From: FlyInWind <2518509078@qq.com> Date: Thu, 6 Jan 2022 16:19:39 +0800 Subject: [PATCH] =?UTF-8?q?caffeine=20=E4=B8=8D=E6=94=AF=E6=8C=81=E5=AD=98?= =?UTF-8?q?=E5=85=A5=20null=20=E7=9A=84=20value=EF=BC=8C=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E5=8C=85=E8=A3=85=E6=88=90=20NullValue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/cache/support/RedisCaffeineCache.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/pig4cloud/plugin/cache/support/RedisCaffeineCache.java b/src/main/java/com/pig4cloud/plugin/cache/support/RedisCaffeineCache.java index 410d516..36bc0d3 100755 --- a/src/main/java/com/pig4cloud/plugin/cache/support/RedisCaffeineCache.java +++ b/src/main/java/com/pig4cloud/plugin/cache/support/RedisCaffeineCache.java @@ -97,11 +97,12 @@ public void put(Object key, Object value) { return; } long expire = getExpire(); + value = toStoreValue(value); if (expire > 0) { - stringKeyRedisTemplate.opsForValue().set(getKey(key), toStoreValue(value), expire, TimeUnit.MILLISECONDS); + stringKeyRedisTemplate.opsForValue().set(getKey(key), value, expire, TimeUnit.MILLISECONDS); } else { - stringKeyRedisTemplate.opsForValue().set(getKey(key), toStoreValue(value)); + stringKeyRedisTemplate.opsForValue().set(getKey(key), value); } push(new CacheMessage(this.name, key)); @@ -118,17 +119,17 @@ public ValueWrapper putIfAbsent(Object key, Object value) { prevValue = stringKeyRedisTemplate.opsForValue().get(cacheKey); if (prevValue == null) { long expire = getExpire(); + value = toStoreValue(value); if (expire > 0) { - stringKeyRedisTemplate.opsForValue().set(getKey(key), toStoreValue(value), expire, - TimeUnit.MILLISECONDS); + stringKeyRedisTemplate.opsForValue().set(getKey(key), value, expire, TimeUnit.MILLISECONDS); } else { - stringKeyRedisTemplate.opsForValue().set(getKey(key), toStoreValue(value)); + stringKeyRedisTemplate.opsForValue().set(getKey(key), value); } push(new CacheMessage(this.name, key)); - caffeineCache.put(key, toStoreValue(value)); + caffeineCache.put(key, value); } } return toValueWrapper(prevValue);