Commit 4f89efa8 by WeiCong

调整缓存模块

parent 18242105
...@@ -38,6 +38,19 @@ public class RedisCache extends AbstractCache { ...@@ -38,6 +38,19 @@ public class RedisCache extends AbstractCache {
} }
@Override @Override
public Object cacheRead(String key, long l) {
try {
Object val = RedisUtil.get(key);
if (val != null) {
RedisUtil.set(key, val, (int) l);
}
return val;
} catch (Exception e) {
throw new NoUiException("从缓存[" + this.cacheName + "]中获取key=" + key + "的值出现异常", e);
}
}
@Override
public boolean cacheWrite(String key, Object val) { public boolean cacheWrite(String key, Object val) {
try { try {
RedisUtil.set(key, val); RedisUtil.set(key, val);
...@@ -46,4 +59,14 @@ public class RedisCache extends AbstractCache { ...@@ -46,4 +59,14 @@ public class RedisCache extends AbstractCache {
throw new NoUiException("将key=" + key + "的值放入缓存[" + this.cacheName + "]出现异常", e); throw new NoUiException("将key=" + key + "的值放入缓存[" + this.cacheName + "]出现异常", e);
} }
} }
@Override
public boolean cacheWrite(String key, Object val, long l) {
try {
RedisUtil.set(key, val, (int) l);
return true;
} catch (Exception e) {
throw new NoUiException("将key=" + key + "的值放入缓存[" + this.cacheName + "]出现异常", e);
}
}
} }
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