Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 29 23:39
    scala-steward opened #616
  • Nov 28 14:40
    scala-steward opened #615
  • Nov 28 11:40
    ronnnnnnnnnnnnn commented #603
  • Nov 24 11:41
    kryptt commented #352
  • Nov 23 06:15

    lewisjkl on unidoc

    (compare)

  • Nov 23 06:15

    lewisjkl on master

    add unidoc update workflow update unidoc to only run on 2.… and 3 more (compare)

  • Nov 23 06:15
    lewisjkl closed #613
  • Nov 23 06:15
    lewisjkl synchronize #613
  • Nov 23 06:15

    lewisjkl on unidoc

    Update scalafmt-core to 3.1.2 Reformat with scalafmt 3.1.2 Merge pull request #614 from sc… and 1 more (compare)

  • Nov 22 07:26

    mergify[bot] on master

    Update scalafmt-core to 3.1.2 Reformat with scalafmt 3.1.2 Merge pull request #614 from sc… (compare)

  • Nov 22 07:26
    mergify[bot] closed #614
  • Nov 22 07:22
    scala-steward opened #614
  • Nov 22 05:56
    lewisjkl synchronize #613
  • Nov 22 05:56

    lewisjkl on unidoc

    add quotes around scala version (compare)

  • Nov 22 05:50
    lewisjkl synchronize #613
  • Nov 22 05:50

    lewisjkl on unidoc

    update unidoc to only run on 2.… (compare)

  • Nov 21 22:12
    lewisjkl synchronize #613
  • Nov 21 22:12

    lewisjkl on unidoc

    update workflow (compare)

  • Nov 21 21:16
    lewisjkl edited #613
  • Nov 21 21:15
    lewisjkl opened #613
Roberto Leibman
@rleibman
I hope you don't mind... I'm actually using it, so I put in a PR for it.
Roberto Leibman
@rleibman
@cb372 Can you look at my PR please?
Roberto Leibman
@rleibman
bump
bengraygh
@bengraygh

How do I remove from a cache? In the example above, I've tried removing by the user, and by the userId, but neither of those worked. Only removeAll worked

I think I have figured out why this is happening to you, but am not sure what is the best way to fix it. Did you find a solution?

I think the problem is that the method call is part of the key stored by scalacache, and calling it from a different method causes a cache miss.

Miguel Vilá
@miguel-vila
hello :wave: , we have observed some strange behavior when using scalacache along with ZIO. We are using a Task mode and we noticed that the parameters were not being included as part of the key. We factored out the code by extracting the underlying operation and it worked as expected, will link some gist
you can see the differences between the working version and the non working version there
so I'm wondering if this is something that's expected? were we missusing scalacache?
Roberto Leibman
@rleibman
@miguel-vila I didn't know there was even an official zio mode. I put a PR back in April but haven't heard anything since.
sc6l6d3v
@sc6l6d3v
Is there any possibility of caching an fs2 stream?
Simon Redfern
@simonredfern_gitlab
Folks, Nubeee here. How do I make the following work with maven?: import scalacache.serialization.binary._
PawelJ-PL
@PawelJ-PL
Hi, I'm wonder why traits Cache and CacheAlg doesn't include effect type parameter (it was moved to methods declarations). I've just created an issue for this (cb372/scalacache#417), where I've explained my doubts more precisely.
SWAPNIL SONAWANE
@iamswapnil44_twitter
Folks, Is there any way to retrive all the keys from Caffeine cache ?
Brendan Maguire
@brendanmaguire

Hi. Hoping someone can help with a question I have regarding using scalacache with cats.effect.IO. If I run the following code:

import cats.effect.{ExitCode, IO, IOApp}
import cats.implicits._
import scalacache.guava.GuavaCache
import scalacache.{cachingF, CacheConfig, Flags}

import scala.concurrent.duration.DurationLong

object CacheTest extends IOApp {

  override def run(args: List[String]): IO[ExitCode] =
    (
      cached("abc"),
      cached("abc"),
      cached("def")
    ).parMapN(_ + _ + _) *> IO.pure(ExitCode.Success)

  private val cache = GuavaCache[String](CacheConfig.defaultCacheConfig)

  private def cached(key: String) =
    cachingF(key)(ttl = None)(loadValue(key))(cache, scalacache.CatsEffect.modes.async, Flags.defaultFlags)

  private def loadValue(key: String) =
    IO(println(s"Loading $key")) *>
      IO.sleep(1.second) *>
      IO {
        println(s"Loaded $key")
        key
      }
}

I get the output:

Loading abc
Loading abc
Loading def
Loaded abc
Loaded abc
Loaded def

cachingF invokes the loadValue function twice with "abc". Instead I would like it to only invoke it once and use the resulting IO for both calls to cached. Is this possible using scalacache or do I need to implement this manually by storing an actual IO in the cache and removing the key if the IO fails at a later stage?

SWAPNIL SONAWANE
@iamswapnil44_twitter

Hello All,

Is there any way to get the redis cache stats like hit rate , hit count as we get it for caffaine by using caffainecache.stats.hitCount()

SWAPNIL SONAWANE
@iamswapnil44_twitter

Hello All ,

Is there any way to provide custom codecs for redis cache.

here is my code :

def creatCache[T](implicit  codec: Codec[T]) = {
      val jedisPool = new JedisPool(new JedisPoolConfig(), "localhost", 6379, 20000)
      val customisedRedisCache: Cache[T] = RedisCache[T](jedisPool)
      customisedRedisCache
}

and calling this function as

 implicit val jobPropsCache = creatCache[Map[String,String]]

code is failing at calling thr function. error is

 No implicits provides for codec: Codec[Map[String,String]]
Yoann Guyot
@ygu

Hi there, I'm migrating from scala 2.12 to 2.13, including code that was written using scalacache and guava. But now the compiler refuses that code. These are the issues:

import scalacache._
import scalacache.serialization.InMemoryRepr
import guava._

class MyClass(cache: ScalaCache[InMemoryRepr]) {...}

gives me : object InMemoryRepr is not a member of package scalacache.serialization and: not found: type ScalaCache

Also:
sync.cachingWithTTL(key)(Duration.apply(1, DAYS)) { ... }

gives me: value cachingWithTTL is not a member of object scalacache.sync

Finally:
ScalaCache(GuavaCache())

gives me:

overloaded method apply with alternatives:
[error]   [V](underlying: com.google.common.cache.Cache[String,scalacache.Entry[V]])(implicit config: scalacache.CacheConfig): scalacache.guava.GuavaCache[V] <and>
[error]   [V](implicit config: scalacache.CacheConfig): scalacache.guava.GuavaCache[V]
[error]  cannot be applied to ()

Anyone to help migrating to last version of scalacache (I can't find any scaladoc or changelog to help replacing the old code) ?
So, what should I use instead of scalacache.serialization.InMemoryRepr which seems to have been removed from the library.
Why is ScalaCache not found ?
What should I use instead of sync.cachingWithTTL ?
How to use the new constructors of GuavaCache to get the same as old GuavaCache() ? Isn't there a default one ?

@cosmir17 it seems you've experienced the same kind of issue, have you found out how to fix it ?
Yoann Guyot
@ygu

I may have found answers:

  • I use GuavaCache[MyClass] instead of ScalaCache[InMemoryRepr]
  • I use sync.caching(key)(Some(Duration.apply(1, DAYS))) { ... }(cache = myImplicitCache, mode = mode, flags = new Flags()) instead of sync.cachingWithTTL(key)(Duration.apply(1, DAYS)) { ... }
  • I use GuavaCache(config) with implicit val config = CacheConfig() instead of ScalaCache(GuavaCache())

I hope this is correct.

Roberto Leibman
@rleibman
Are there any facilities for multi-level layering of cache systems in either scalacache or in any of the cache systems that scalacache uses? Basically I'd like a short TTL for in memory cache and a a longer TTL for a cloud level cache before I hit the actual process that gets the data.
Roberto Leibman
@rleibman
It may not be too difficult to create a CompoundCache that extends AbstractCache and has a list of caches to try
Jeff Lewis
@lewisjkl
Hey @rleibman I don’t believe that there is a current “out-of-the-box” way to do this. But I agree that you could pretty easily create a compound cache of some kind that did this. We have an issue open to take a look at the API Scalacache exposes before we go live with a final 1.0.0 release and will keep this in mind while going through that exercise.
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?