51 lines
1.3 KiB
Java
51 lines
1.3 KiB
Java
package com.engine.salary.service.impl;
|
|
|
|
import com.cloudstore.dev.api.util.Util_DataCache;
|
|
import com.engine.salary.service.SalaryCacheService;
|
|
import com.engine.salary.util.JsonUtil;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import weaver.general.Util;
|
|
|
|
public class SalaryCacheServiceImpl implements SalaryCacheService {
|
|
|
|
|
|
@Override
|
|
public <T> void set(String key, T value) {
|
|
Util_DataCache.setObjVal(key, value);
|
|
}
|
|
|
|
@Override
|
|
public <T> void set(String key, T value, int time) {
|
|
Util_DataCache.setObjVal(key, value, time);
|
|
}
|
|
|
|
@Override
|
|
public <T> void setJson(String key, T value) {
|
|
Util_DataCache.setObjVal(key, JsonUtil.toJsonString(value));
|
|
}
|
|
|
|
@Override
|
|
public <T> void setJson(String key, T value, int time) {
|
|
Util_DataCache.setObjVal(key, JsonUtil.toJsonString(value), time);
|
|
}
|
|
|
|
@Override
|
|
public <T> T get(String key) {
|
|
return (T) Util_DataCache.getObjVal(key);
|
|
}
|
|
|
|
@Override
|
|
public <T> T getJson(String key, Class<T> clazz) {
|
|
String value = Util.null2String(Util_DataCache.getObjVal(key));
|
|
if (StringUtils.isEmpty(value)) {
|
|
return null;
|
|
}
|
|
return JsonUtil.parseObject(value, clazz);
|
|
}
|
|
|
|
@Override
|
|
public void remove(String key) {
|
|
Util_DataCache.clearVal(key);
|
|
}
|
|
}
|