我只是想知道Scala中是否有任何缓存解决方案.我正在寻找类似于Java中的Guava提供的东西.
我应该在Scala中使用Guava吗?Scalaz中是否有包装/皮条客或类似的东西?任何更适合Scala开发者的替代方案?
番石榴提供的是什么:
LoadingCache<Key, Graph> CACHE= CacheBuilder.newBuilder()
.maximumSize(1000)
.expireAfterWrite(10, TimeUnit.MINUTES)
.removalListener(MY_LISTENER)
.build(
new CacheLoader<Key, Graph>() {
public Graph load(Key key) throws AnyException {
return createExpensiveGraph(key);
}
});
Supplier<Animal> singleAnimalCache = Suppliers.memoizeWithExpiration(animalFromDbSupplier(), 365, TimeUnit.DAYS);
Run Code Online (Sandbox Code Playgroud)
我需要像Guava一样的基本缓存管理.