mergify[bot] on master
Update cats-effect, cats-effect… Merge pull request #680 from sc… (compare)
mergify[bot] on master
Update scalatest to 3.2.12 Merge pull request #674 from sc… (compare)
Mode
for ZIO effects ?
Hi! If I use caffeine cache with expireAfterWrite set, not sure how the ttl param would behave in cachingF?
private val underlyingCaffeineCache = Caffeine.newBuilder()
.initialCapacity(1000)
.maximumSize(10000L)
.expireAfterWrite(60, TimeUnit.SECONDS)
.buildString, Entry[T]
implicit val caffeineCache: Cache[T] = CaffeineCache(underlyingCaffeineCache)
cachingF(key)(ttl.some)
Hi Team,
We are using below library dependencies in our scala App:
"com.github.cb372" %% "scalacache-redis" % "0.28.0",
"com.github.cb372" %% "scalacache-cats-effect" % "0.28.0"
We are planning to upgrade our scala app from 2.12 to 3.0.0. Are there any plans from scalacache's end to release next version compatible with scala 3 ?
import scalacache.memoization._
import scala.concurrent.duration._
import scalacache.caffeine._
import scala.concurrent.Future
implicit val cache: CaffeineCache[String] = CaffeineCache[String]
import scalacache.modes.scalaFuture._
import scala.concurrent.ExecutionContext.Implicits.global
def memFut(s: String): Future[String] = memoize(Option(30.seconds)) {
Future(s) // I want to be able to cache an async call here
}
Future[A]
?
CaffeineCache[Future[String]]
None
on a cache-miss i.e. conditional caching? would prefer not to populate the cache with None
myselfget
) without updating/refreshing the TTL i.e. conditional refreshing, TTL-checking?Though I've used scalacache for quite a while now, I'm having issues with a cache that is being hit by multiple threads at a time. Is there any synchronization I need to provide or anything like that?
I simply do:
cachingF("TenantTransactor", serverIndex)(None) { /*code here*/ }
And I see multiple misses for the same key before I finally get an insertion:
2021-09-20 16:56:01,051 [DEBUG] from scalacache.caffeine.CaffeineCache in zio-default-async-14 - Cache miss for key TenantTransactor:0
2021-09-20 16:56:01,204 [DEBUG] from scalacache.caffeine.CaffeineCache in zio-default-async-5 - Cache miss for key TenantTransactor:0
2021-09-20 16:56:01,389 [DEBUG] from scalacache.caffeine.CaffeineCache in zio-default-async-11 - Cache miss for key TenantTransactor:0
2021-09-20 16:56:01,748 [DEBUG] from scalacache.caffeine.CaffeineCache in zio-default-async-7 - Cache miss for key TenantTransactor:0
2021-09-20 16:56:01,923 [DEBUG] from scalacache.caffeine.CaffeineCache in zio-default-async-2 - Cache miss for key TenantTransactor:0
2021-09-20 16:56:02,102 [DEBUG] from scalacache.caffeine.CaffeineCache in zio-default-async-14 - Inserted value into cache with key TenantTransactor:0
2021-09-20 16:56:02,102 [DEBUG] from scalacache.caffeine.CaffeineCache in zio-default-async-19 - Cache hit for key TenantTransactor:0
cats-effect
module is gone (looks like it's being integrated into core
) and Mode
is also MIA.... Does it mean now CE is the only supported effect runtime?
Hello,
Trying to use scalacache
for the first time, I think that I follow the documentation scrupulously but I have an error related to implicit. Does somebody can help on this? Thanks
scala> import scalacache._
| import scalacache.caffeine._
| import com.github.benmanes.caffeine.cache.Caffeine
| import java.util.concurrent.TimeUnit
|
| val underlying = Caffeine
| .newBuilder()
| .expireAfterWrite(1, TimeUnit.HOURS)
| .maximumSize(100)
| .build[Int, Entry[String]]()
|
| val cache = CaffeineCache(underlying)
val cache = CaffeineCache(underlying)
^
On line 12: error: overloaded method apply with alternatives:
[V](underlying: com.github.benmanes.caffeine.cache.Cache[String,scalacache.Entry[V]])(implicit config: scalacache.CacheConfig): scalacache.caffeine.CaffeineCache[V] <and>
[V](implicit config: scalacache.CacheConfig): scalacache.caffeine.CaffeineCache[V]
cannot be applied to (com.github.benmanes.caffeine.cache.Cache[Int,scalacache.Entry[String]])
scalacache version is 0.28.0
java 8
val cache
is a eager and non-IO...) Or it's related to my CacheOpts wrapper? Any help appreciated :slight_smile: case class CacheOpts[T, F[_]](ttl: Option[Duration], cache: Cache[T], mode: Mode[F], flags: Flags)
object CacheOpts {
def asyncGuava[T, F[_]: Async](ttl: Option[Duration]): CacheOpts[T, F, GuavaCache[T]] = CacheOpts(
ttl,
GuavaCache[T],
scalacache.CatsEffect.modes.async[F],
Flags.defaultFlags
)
}
class Test {
val cache = CacheOpts.asyncGuava[OtherClass](100.seconds)
def doIt(useCache: Boolean) =
if (useCache) OtherClass.heavyRequestMemo
else OtherClass.heavyRequest
}
object OtherClass {
def heavyRequestMemo(@cacheKeyExclude cacheOpts: CacheOpts[GithubSource, IO])(otherParams: Int): IO[OtherClass] =
memoizeF(cacheOpts.ttl) {
heavyRequest(otherParams)
}(cacheOpts.cache, cacheOpts.mode, cacheOpts.flags)
}
Hi!
I'm trying to override logCacheHitOrMiss to generate some metrics but I'm having the following problem when compiling:
"incompatible type in overriding
[error] protected def jedisPool: redis.clients.util.Pool[CustomRedisCache.this.JClient] (defined in trait RedisCacheBase)
[error] with val jedisPool: redis.clients.jedis.JedisPool (defined in class RedisCache);
[error] found : redis.clients.jedis.JedisPool
[error] required: redis.clients.util.Pool[CustomRedisCache.this.JClient]
[error] (which expands to) redis.clients.util.Pool[redis.clients.jedis.Jedis];"
any idea how to solve this?