All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alogic.load.Store Maven / Gradle / Ivy

There is a newer version: 1.6.17
Show newest version
package com.alogic.load;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Store
 * 
 * 

* Store是在Loader的基础上增加存储接口 * * @author yyduan * * @param */ public interface Store extends Loader { /** * 存储对象 * @param id 对象id * @param o 对象实例 * @param overwrite 是否覆盖 * */ public void save(String id,O o,boolean overwrite); /** * 删除指定的对象 * @param id 对象id */ public void del(String id); /** * 基于本地内存ConcurrentHashMap的Store * * @author yyduan * */ public static class HashStore extends Loader.Sinkable implements Store{ protected Map data = new ConcurrentHashMap(); @Override public void save(String id, O o, boolean overwrite) { O found = data.get(id); if (found == null){ data.put(id, o); }else{ if (overwrite){ data.put(id, o); } } } @Override protected O loadFromSelf(String id, boolean cacheAllowed) { return data.get(id); } @Override public void del(String id){ data.remove(id); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy