com.feingto.cloud.cache.provider.DefaultDataDictProvider Maven / Gradle / Ivy
package com.feingto.cloud.cache.provider;
import com.feingto.cloud.cache.IDataDictCache;
import com.google.common.collect.Maps;
import java.util.List;
import java.util.Map;
/**
* 数据缓存实现
*
* @author longfei
*/
@SuppressWarnings("unchecked")
public class DefaultDataDictProvider implements IDataDictCache {
private Map data = Maps.newHashMap();
private boolean isLoaded = false;
@Override
public Object get(String key) {
if (!this.isLoaded) {
this.sync();
}
return this.data.get(key);
}
@Override
public synchronized boolean sync() {
this.isLoaded = true;
return true;
}
@Override
public List getList(String key) {
if (!this.isLoaded) {
this.sync();
}
return (List) this.data.get(key);
}
@Override
public Map getMap(String key) {
if (!this.isLoaded) {
this.sync();
}
return (Map) this.data.get(key);
}
@Override
public void put(String key, Object data) {
if (!this.isLoaded) {
this.sync();
}
}
@Override
public boolean has(String key) {
return this.data.containsKey(key);
}
@Override
public void remove(String key) {
this.data.remove(key);
}
@Override
public void clear() {
this.data.clear();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy