Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 16 04:21
    scala-steward opened #313
  • Oct 14 11:20
    scala-steward opened #312
  • Oct 14 11:20
    scala-steward opened #311
  • Oct 11 22:15
    scala-steward opened #310
  • Oct 01 20:24
    scala-steward opened #309
  • Sep 28 04:24
    scala-steward opened #308
  • Sep 27 12:27
    dieproht edited #307
  • Sep 27 07:00
    dieproht synchronize #307
  • Sep 27 06:37
    dieproht synchronize #307
  • Sep 27 06:29
    dieproht opened #307
  • Sep 26 05:22
    scala-steward opened #306
  • Sep 20 18:32
    scala-steward opened #305
  • Sep 18 15:10
    scala-steward opened #304
  • Sep 18 15:08
    scala-steward opened #303
  • Sep 17 21:39
    leonardehrenfried closed #302
  • Sep 17 21:39
    leonardehrenfried commented #302
  • Sep 17 21:34
    leonardehrenfried opened #302
  • Sep 16 12:52
    scala-steward opened #301
  • Sep 16 02:33
    scala-steward opened #300
  • Sep 14 17:59
    cb372 closed #260
Ben Zumhagen
@bzumhagen
will return between 3 and 8 typically
instead of the desired 1
With this operation obviously it's not a big deal, but with more expensive operations it adds up
Ben Zumhagen
@bzumhagen
SO I did a little more digging, and it looks like to recommended way to use Caffeine is to cache.get(key, k -> value) to atomically compute and insert the value into the cache to avoid racing with other writes
But I see in the scalacache-caffeine impl it uses getIfPresent
def doGet[F[_]](key: String)(implicit mode: Mode[F]): F[Option[V]] = {
    mode.M.delay {
      val entry = underlying.getIfPresent(key)
      val result = {
        if (entry == null || entry.isExpired)
          None
        else
          Some(entry.value)
      }
      logCacheHitOrMiss(key, result)
      result
    }
  }
Ben Zumhagen
@bzumhagen
can someone explain or point me the linkage between memoize and this doGet?
Bijan Chokoufe Nejad
@bijancn

Hey guys. Is there any release which uses cats-effects 1.0.0-RC or 1.0.0-RC2? I am getting errors like this

[error] java.lang.NoSuchMethodError: cats.effect.IO$.ioConcurrentEffect()Lcats/effect/ConcurrentEffect;
[error]         at scalacache.CatsEffect$modes$$anon$2.<init>(CatsEffect.scala:16)                                 
[error]         at scalacache.CatsEffect$modes$.<init>(CatsEffect.scala:15)                        
[error]         at scalacache.CatsEffect$modes$.<clinit>(CatsEffect.scala)

when trying to combine scalacache with http4s 0.19

Jules Ivanic
@guizmaii
@bijancn no
We're waiting for the 1.0.0 release
Bijan Chokoufe Nejad
@bijancn
:disappointed: do you know the approximate timeline for that release?
Bijan Chokoufe Nejad
@bijancn
okay nvm. Nobody knows. Thanks for the info though
Jules Ivanic
@guizmaii

do you know the approximate timeline for that release?

No

IMHO, not before september or october

@bijancn it should be easy to update the Cats version and publish your version ;)
Bijan Chokoufe Nejad
@bijancn
Do you think? I would expect some breaking changes?
Chetan Kumar
@chetankm-cs
I am implementing a cache which is caching some api with some TTL.
I am not able to figure out how to do error handling, since cachingF will cache error also.
Wojtek Pituła
@Krever
Hey! I have never used scalacache before, but now I'm in need of key-value store, most probably redis, and I'm considering using scalacache as an API. Do you think it's reasonable or should I just use some redis client? Side question: would I have access to some more advanced redis features if I need them or I can use only things that are covered by an API? I have not yet gone through docs, so if I will find all info there just tell me ;)
I'm mostly encouraged by being able to choose my effect type, if I remember correctly from scallar and this is indeed feature of scalacache.
Bijan Chokoufe Nejad
@bijancn
@Krever I can only say that the API for the inmemory cache is exactly what I would expect from a functional library :wink:
Mike Limansky
@limansky

Hi! Could anybody help me with Id type? What is the proper way to get rid of it. I mean, I have a cache:

class Foo {
  import scalacache.modes.sync._

   private val cache = EhCache[String](.....)

   def doSomething(x: Int): String = {
     cache.caching(x)(None){
       calculateValue(x)
     }
  }
}

This will not compile because result type must be String but caching returns [F[_]]F[String]. There is special "sync" version of memoize, but there no such functions for the Cacheclass itself. I've found that if i just create variable and return it it works fine, but for me it looks quite ugly.

I can change return type to Id[String], but I don't want to expose these details outside of class Foo.
Bijan Chokoufe Nejad
@bijancn
type Id[X] = X so I don't think this is the problem
Diego E. Alonso Blas
@diesalbla

Good afternoon.
I have a question about the code of the CacheAlg file trait https://github.com/cb372/scalacache/blob/master/modules/core/shared/src/main/scala/scalacache/CacheAlg.scala
Usually, algebras with operations parametric on a parametric type F[_], like this one, declare that parameter on the top of the trait, i.e.

trait CacheAlg[V, F[_] ]

This way allows the implementations to bind the F[_] to a specific effect, such as F = doobie.ConnectionIO for a database. If the F[_] is declared on the methods, inheritors cannot spesialise the F[_].
Was there a specific reason, in this case, for taking this route F[_] on each abstract method?

Taylor Brown
@tbrown1979
@diesalbla I sort of asked that question back in june, in this chat
You can find Chris Birchall's response back then as well
Mohanraj Nagasamy
@mohanraj-nagasamy

Hi Im using scalacache with Cats-Effects - How do I cache a method which returns EitherT[IO, Exception, Option[String]] not IO

Look at the find method - I want to cache the result of it and return the errors to caller if there is one

import cats.data.EitherT
import cats.effect.IO
import scalacache.redis.RedisCache
import scalacache.{Cache, CatsEffect, Mode, cachingF}
import scalacache.serialization.binary._

def find(key: Int, boolean: Boolean): EitherT[IO, Exception, Option[String]] = {
  val map = Map(1 -> "one", 2 -> "two")
  if (boolean) {
    EitherT.right(IO.pure(map.get(key)))
  } else {
    EitherT.leftT(new RuntimeException("validation failed"))
  }
}

implicit val catsCache: Cache[Int] = RedisCache("localhost", 6379)
implicit val mode: Mode[IO] = CatsEffect.modes.io

//Doesn't compile
val result = cachingF("key1")(ttl = None) {
  find(1, true).value
}

result.unsafeRunSync()

result doesn't compile which expects implicts for the EitherT type.

Nafer Sanabria
@naferx
Hi @cb372 ,
Do recent versions of scalacache support Guava LoadingCache ?
I spotted this issue cb372/scalacache#108
Currently, I'm using 0.21.0. Thanks in advance
Matthew de Detrich
@mdedetrich
Any idea when a new release will be made with cb372/scalacache#205 ?
i.e. an updated version of Circe
Nick
@gurinderu
@mohanraj-nagasamy try to change your mode to scalacache.CatsEffect.modes.async and remove .value, also i see that you have a wrong cache type, it should be Cache[Option[String]]
Shawn Garner
@BusyByte
hello
I'm trying to write a spec and would like a cache for testing which is not the real redis one. Is there a memory/hashmap based one or something available?
Mohanraj Nagasamy
@mohanraj-nagasamy
@gurinderu Thanks Nick! Any idea how do I avoid caching exceptions or exclude exceptions/validations from getting cached?
Nick
@gurinderu
@mohanraj-nagasamy don't use exceptions dude) but if you can't you can wrap your code to Try and then transform this to OptionT or EitherT
Dominic Egger
@GrafBlutwurst
Hey I am working on a very simple PR for easily wrapping caches in Resource[F[_], E] from cats
GrafBlutwurst/scalacache@b2f55bd
but I'm struggling with coming up with a clean solution for partial application of types to avoid having to specify the V parameter
does anyone have a good idea?
maybe it'd be better to pass F[Cache[V]] rather than thunk: => Cache[V]. Though ideally I'd like to enable the following syntax:
resourceCache[IO] {
    //cache init
    Cache[V]
}
Anton
@atk91
Hi everyone! Is it possible to get total weight of objects in cache with Caffeine behind?
liadkaradi
@liadkaradi
Hi All,
I'm trying to use a custom cacheConfig object (in order to control cache key creation). I've created an instance of it and have added it to my scope as an implicit value. So far I see that my custom implementation is not being taken into account (my breakpoint is being ignored). Can someone give me a concrete example of such a custom use? Thanks in advance.
Brian P. Holt
@bpholt
Is the scalacache-twitter-util module published anywhere? I don't see it in Maven Central
Paulo "JCranky" Siqueira
@jcranky
Hi. I just tried to update scalacache to 0.28.0 and noticed it is already depending on cats 2 milestones... is that on purpose?
Wojtek Pituła
@Krever
@jcranky cant answer the question but why is that a problem? cats 2 should be bin-compat with cats 1
Paulo "JCranky" Siqueira
@jcranky
should, but why take the risk in a production system, while it is still a Milestone?
Arunav Sanyal
@Khalian
is there documentation on how to create a Caffeine scala cache. I am looking at this https://cb372.github.io/scalacache/docs/index.html and it only says "use caffeine if you want to use a high performance cache"
Arunav Sanyal
@Khalian
nvm, i figured it out : private val accountSPCache = CaffeineCache(Caffeine.newBuilder.build[String, Entry[List[String]]]). Can someone please add this (and every other version) into the documentation so that people do not have to go look at unit tests. Thanks
Arunav Sanyal
@Khalian
in the example | val result = caching("benjamin")(ttl = None) - what does ttl None mean? does it mean the ttl is now the same as the underlying cache init one OR does it imply that there is no ttl, this is meant to live till infinity
Sean Kwak
@cosmir17

Hi :) I used scalacache version, 0.10.0 for scalacache-core & scala-caffeine. I upgraded to "0.28.0"

The following code stopped being compiled..

  implicit private val inMemoryCache: ScalaCache[InMemoryRepr] = ScalaCache(CaffeineCache())
  private val CacheTime = 10.seconds
  def myMethod: Future[Boolean] = memoizeSync(CacheTime) {.....}

Can I ask how I can migrate to 0.28.0?

I have changed the first line to

  implicit private val inMemoryCache: Cache[Future[Boolean]] = CaffeineCache[Future[Boolean]]

It compiles but I don't feel that it is the right approach..

Bijan Chokoufe Nejad
@bijancn
Hey @here . Is there a release planned with cats effect 2.0 ?