gpt4 book ai didi

scala - Scala 中的轻量级缓存解决方案?

转载 作者:行者123 更新时间:2023-12-04 02:02:52 25 4
gpt4 key购买 nike

我只是想知道 Scala 中是否有任何可用的缓存解决方案。
我正在寻找类似于 Guava 在 Java 中提供的东西。

我应该在 Scala 中也使用 Guava 吗?
Scalaz 中是否有包装器/皮条客或类似的东西?
任何更适合 Scala 开发人员的替代方案?

Guava 提供什么:

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);

我需要一些基本的缓存管理,比如在 Guava 中。

最佳答案

Is there a wrapper / pimp in Scalaz or something similar?



在 Scalaz 7 中有 Memo ,我在 learning Scalaz day 16 中稍微介绍了一下.

这是 Adam Rosien 在 scalaz "For the Rest of Us" 中介绍的第一件事说话,所以也检查一下。他正在使用 Scalaz 6。

关于scala - Scala 中的轻量级缓存解决方案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13636475/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com