如何将一组哈希图插入缓存?
执行以下代码后,我得到了以下异常。
net.sf.jsr107cache.CacheException: Could not find class: 'ri.cache.BasicCacheFactory'
at net.sf.jsr107cache.CacheManager.getCacheFactory(CacheManager.java:46)
at InsertIntoCACHE.main(InsertIntoCACHE.java:17)
我想用字符串作为键插入一个哈希图作为值。非常感谢任何帮助
import java.io.IOException;
import java.util.HashMap;
import java.util.Collections;
import net.sf.jsr107cache.Cache;
import net.sf.jsr107cache.CacheException;
import net.sf.jsr107cache.CacheFactory;
import net.sf.jsr107cache.CacheManager;
public class InsertIntoCACHE {
public static void main(String[] args) throws IOException {
Cache cache;
try {
CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
cache = cacheFactory.createCache(Collections.emptyMap());
String key="21";
byte[] value=("Twenty One").getBytes();
cache.put(key, value);
value = (byte[]) cache.get(key);
System.out.println(value);
} catch (CacheException e) {
e.printStackTrace();
}
}
}