我正在尝试将redis集成到scalacache。键通常是字符串,但值可以是对象、设置[string]等。缓存由以下项初始化

val cache: RedisCache = RedisCache(config.host, config.port)
private implicit val scalaCache: ScalaCache[Array[Byte]] = ScalaCache(cacheService.cache)

但是在调用put时,我得到了这个错误“找不到类型set[string]和repr的任何编解码器”。看起来我需要为我的缓存输入提供编解码器,正如我建议的那样,所以我添加了,
class A extends Codec[Set[String], Array[Byte]] with GZippingBinaryCodec[Set[String]]

即使之后,我的A班也犯了同样的错误。我错过了什么。

最佳答案

正如您在link中提到的,您可以以二进制格式序列化值:

import scalacache.serialization.binary._

或者使用circe作为json:
 import scalacache.serialization.circe._
 import io.circe.generic.auto._

08-28 01:36