Commit 6390709d by 陈文顺

redis

parent 8090d641
...@@ -56,7 +56,7 @@ public class DictRedisCache extends RedisCache<DictTypeDto> { ...@@ -56,7 +56,7 @@ public class DictRedisCache extends RedisCache<DictTypeDto> {
@Override @Override
public int getExprie() { public int getExprie() {
return 60*60*24;//24小时 return 24;//24小时
} }
} }
...@@ -38,10 +38,10 @@ public abstract class RedisCache<T> { ...@@ -38,10 +38,10 @@ public abstract class RedisCache<T> {
value = searchDB(key); value = searchDB(key);
if (value == null){ if (value == null){
redisUitl.setEx(redisKey, "",30, TimeUnit.SECONDS); redisUitl.setEx(redisKey, "",5, TimeUnit.MINUTES);
}else { }else {
redisUitl.setEx( redisKey,value, getExprie(), TimeUnit.SECONDS); redisUitl.setEx( redisKey,value, getExprie(), TimeUnit.HOURS);
} }
return value; return value;
......
...@@ -68,12 +68,13 @@ public abstract class RedisHashCache<T> { ...@@ -68,12 +68,13 @@ public abstract class RedisHashCache<T> {
if (map == null || map.size() == 0){ if (map == null || map.size() == 0){
redisTemplate.boundHashOps(getRedisKey(key)).put("",""); redisTemplate.boundHashOps(getRedisKey(key)).put("","");
redisTemplate.expire(getRedisKey(key),5,TimeUnit.MINUTES);
}else { }else {
redisTemplate.boundHashOps(getRedisKey(key)).putAll(map); redisTemplate.boundHashOps(getRedisKey(key)).putAll(map);
}
redisTemplate.expire(getRedisKey(key),getExprie(),TimeUnit.HOURS); redisTemplate.expire(getRedisKey(key),getExprie(),TimeUnit.HOURS);
}
result = (Map<String,T>)redisTemplate.boundHashOps(getRedisKey(key)).entries(); result = (Map<String,T>)redisTemplate.boundHashOps(getRedisKey(key)).entries();
......
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