com.hecloud.runtime.database.cache.EntityCache Maven / Gradle / Ivy
package com.hecloud.runtime.database.cache;
import com.hecloud.runtime.database.emuns.ColumnField;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Optional;
/**
* 用户认证信息缓存
*
* @author LoveinBJ
*/
public class EntityCache extends LinkedHashMap> {
/**
*
*/
private static final long serialVersionUID = 1L;
private int capacity = 16;
public EntityCache(int capacity) {
super(16, 0.75f, true);
if (capacity > 0) {
this.capacity = capacity;
}
}
@Override
protected boolean removeEldestEntry(java.util.Map.Entry> eldest) {
return super.size() > capacity;
}
public synchronized void putCache(String key, List value) {
this.put(key, value);
}
public synchronized List getCache(String key) {
List value = this.get(key);
Optional.ofNullable(value).ifPresent(data -> this.put(key, data));
return value;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy