我只是想知道Scala中是否有任何缓存解决方案. 我正在寻找类似于Guava在Java中提供的东西.
I just wonder if there is any caching solution available in Scala. I'm looking for something like it is provided by Guava in Java.
我也应该在Scala中使用番石榴吗? Scalaz中有包装纸或皮条客吗? 还有其他更适合Scala开发人员的选择吗?
Should I use Guava too in Scala? Is there a wrapper / pimp in Scalaz or something similar? Any alternative more appropriate for Scala devs?
番石榴提供的东西:
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中的
I need some basic cache management like in Guava.
推荐答案
在Scalaz中有包装纸或皮条客吗?
Is there a wrapper / pimp in Scalaz or something similar?
在Scalaz 7中有一个Memo,我在学习Scalaz第16天中对此进行了介绍.
In Scalaz 7 there's Memo, which I covered a bit in learning Scalaz day 16.
这是亚当·罗西恩(Adam Rosien)在 scalaz对于我们其他人"中所涉及的第一件事说话,所以也检查一下.他正在使用Scalaz 6.
It's the first thing Adam Rosien covered in scalaz "For the Rest of Us" talk, so check that out too. He's using Scalaz 6.
更多推荐
Scala中的轻量级缓存解决方案?
发布评论