Commit 4035276a by Future

ehcache

parent d98cc350
...@@ -2,6 +2,7 @@ package com.wecloud.im.service; ...@@ -2,6 +2,7 @@ package com.wecloud.im.service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache; import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
...@@ -27,12 +28,14 @@ public class EhcacheService { ...@@ -27,12 +28,14 @@ public class EhcacheService {
*/ */
public Boolean getIsPush(String key) { public Boolean getIsPush(String key) {
Cache cache = cacheManager.getCache("push"); Cache cache = cacheManager.getCache("push");
Object value = cache.get(key); String value = String.valueOf(cache.get(key));
log.info("ehcache {}", JSON.toJSONString(value)); log.info("ehcache value {}", value);
if (value != null) { if (StringUtils.isNotBlank(value)) {
log.info("not blank {}", value);
return false; return false;
} else { } else {
cache.put(key, 1); log.info("blank");
cache.put(key, "1");
return true; return true;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment