Scala中的轻量级缓存解决方案? [英] Lightweight caching solution in Scala?

查看:288
本文介绍了Scala中的轻量级缓存解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道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中的轻量级缓存解决方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆