Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 20 17:51
    scala-steward closed #634
  • Jan 20 17:51
    scala-steward commented #634
  • Jan 20 17:51
    scala-steward opened #640
  • Jan 14 04:14
    valzam opened #639
  • Jan 13 23:43

    mergify[bot] on master

    Update slf4j-api to 1.7.33 Merge pull request #638 from sc… (compare)

  • Jan 13 23:43
    mergify[bot] closed #638
  • Jan 13 23:39
    scala-steward opened #638
  • Jan 13 14:10
    scala-steward opened #637
  • Jan 12 10:49
    jtjeferreira commented #379
  • Jan 11 17:34

    mergify[bot] on master

    Update sbt-scoverage to 1.9.3 Merge pull request #636 from sc… (compare)

  • Jan 11 17:34
    mergify[bot] closed #636
  • Jan 11 17:29
    scala-steward opened #636
  • Jan 09 08:05

    mergify[bot] on master

    Update cats-effect, cats-effect… Merge pull request #635 from sc… (compare)

  • Jan 09 08:05
    mergify[bot] closed #635
  • Jan 09 08:01
    scala-steward opened #635
  • Jan 02 07:12
    scala-steward closed #628
  • Jan 02 07:12
    scala-steward commented #628
  • Jan 02 07:12
    scala-steward opened #634
  • Jan 01 08:00

    mergify[bot] on master

    Update cats-effect, cats-effect… Merge pull request #633 from sc… (compare)

  • Jan 01 08:00
    mergify[bot] closed #633
Roberto Leibman
@rleibman
Cool!
Jeff Lewis
@lewisjkl
My initial instinct is to wait until after the 1.0.0 release is through to look at introducing this functionality, but very happy to hear your thoughts on that. Feel free to open an issue on GH for this if you feel so inclined :)
Roberto Leibman
@rleibman
I think the only weirdness with it would be that each cache would have it's own ttl vs the ttl of the compound cache.
Jeff Lewis
@lewisjkl
Yeah that is a good callout, thanks for putting the issue in!
Vimit Dhawan
@vimitdhawan
Hello Everyone, I am using CaffeineCache in my application but it looks like we can use only string as a key. is there any way to use case class
Brian P. Holt
@bpholt

When using ScalaCache with cats-effect and Caffeine, is it a good idea to set the Caffeine executor field to the cats-effect Blocker being used?

e.g.

Caffeine.newBuilder().maximumSize(10000L).executor(blocker.blockingContext.execute(_)).build[String, Entry[String]]
Leo De Souza
@cleliofs
Hi all, I am new to Scalacache lib. I am looking for a good introduction to it using Caffeine underlining cache. Any suggestion for an introductory post? I checked the documentation (https://cb372.github.io/scalacache/docs/) but it is quite poor tbh :( For example, which Sbt libs I need to include to support the diff Modes as per "scalacache.modes.try."?
Ashwin Bhaskar
@ashwinbhaskar
is there an integration of scalacache with ZIO?
if not, any pointers on how I should go about building a Mode for ZIO effects ?
Vitalii
@vitamon

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)

danveer4686
@danveer4686

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 ?

Jason Cohen
@jdcohen220
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
}
1 reply
I tried the above based on the examples to memoize an async call that returns a future. The compiler complains that my method needs to return just a string. How can I memoize a method that returns a Future[A] ?
I also tried instantiating cache as CaffeineCache[Future[String]]
danveer4686
@danveer4686
Does anyone know when will lib "scalacache-redis” have scala3 support ?
hughsimpson
@hughsimpson
@danveer4686 I had a stab at providing scala 3 support in a pr, but the repo doesn't look super active right now. Might be worth looking at my branch, but I'm using it pretty simply so there may be something broken that I missed...
Albert Bikeev
@kell18
Hi all!
Could somebody help me to find a way to invalidate the cache? For memoized method
Deepika H
@deepika5555

Hi all.

Is there a way to retrieve all the keys in the cache using scalaCache-guava

Darren Bishop
@DarrenBishop
hi folks. just doing a bit of investigation into whether ScalaCache and some backup can be used for a couple of our use-cases
  1. is it possible to get back nothing e.g. None on a cache-miss i.e. conditional caching? would prefer not to populate the cache with None myself
  2. is it possible to query the cache (do a get) without updating/refreshing the TTL i.e. conditional refreshing, TTL-checking?
Roberto Leibman
@rleibman

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
What could I be missing?
Roberto Leibman
@rleibman
For what it's worth I'm using my own custom spun zio mode, but I tried with cats mode and with sync and they all do the same thing.
Per Øyvind Kanestrøm
@perok
Hi! Would it be possible to do another milestone release with the expiration fixes? :)
yurique
@yurique:nowhere.chat
[m]
plus one to that! :)
vonchav
@voonchav_gitlab
With 1.0.0 branch updated to M4 (with CE 3 support since M3), I'm trying to migrate to M4. Is there a migration guide for v1? I'm seeing the 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?
Ruixi Fan
@rfan-debug
@voonchav_gitlab you can eliminate the dependency of scalacache-cats-effect. Now it is part of core. I just migrated to 1.0.0-M4.
richarddowsett
@richarddowsett
hello. Is there any indication on when 1.0.0 will be made a final release and move away from milestone releases?
samuelsayag
@samuelsayag

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

2 replies
Albert Bikeev
@kell18
Hi all,
Is there a way to make sure cache was used? I use Guava cache implementation and I can see it has underlying stats, is it the metric I should be looking for or there is a better way?
Thank you!
Albert Bikeev
@kell18
Because I have only cache-misses for the following implementation... Is it because of the way I use Cats.IO (even tho 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)
}
1 reply
Albert Bikeev
@kell18
Nevermind, I missed that TTL was too short :expressionless: