Created by ASrivastava on 10/16/17.
*/
object RedisClientTest extends App {
implicit val as = ActorSystem()
val redis = RedisClient(host = "abhisheks-mini")
import Foo.
val result = for {
<- put[Foo]("foo", Foo("Abhishek"))
x <- getFoo
} yield x
println(Await.result(result, Duration.Inf))
case class Foo(name: String)
object Foo {
implicit val fooAvroSer: ByteStringSerializer[Foo] = new ByteStringSerializer[Foo] {...}
}
implicit val fooAvroDeser: ByteStringDeserializer[Foo] = new ByteStringDeserializer[Foo] {...}
}
}`
But you can clearly see that I am explicitly passing the implicit using implicitly as a second parameter. So the error message is wrong. it is unnecessarily forcing me to declare a variable
I have written this code
`import java.io.{ByteArrayInputStream, ByteArrayOutputStream}
import akka.actor.ActorSystem import akka.util.ByteString import com.sksamuel.avro4s.{AvroInputStream, AvroOutputStream} import redis._
import scala.concurrent. import scala.concurrent.duration. import scala.concurrent.ExecutionContext.Implicits.global
/**
Created by ASrivastava on 10/16/17. */ object RedisClientTest extends App { implicit val as = ActorSystem() val redis = RedisClient(host = "abhisheks-mini") import Foo. val result = for { <- put[Foo]("foo", Foo("Abhishek")) x <- getFoo } yield x println(Await.result(result, Duration.Inf))
def put[T](key: String, obj: T) : Future[Boolean] = { redis.set[T](key, obj)(implicitly[ByteStringSerializer[T]]) } def get[T](key: String) : Future[Option[T]] = { redis.getT(implicitly[ByteStringDeserializer[T]]) } }
case class Foo(name: String) object Foo { implicit val fooAvroSer: ByteStringSerializer[Foo] = new ByteStringSerializer[Foo] {...} } implicit val fooAvroDeser: ByteStringDeserializer[Foo] = new ByteStringDeserializer[Foo] {...} } }`
But you can clearly see that I am explicitly passing the implicit using implicitly as a second parameter. So the error message is wrong. it is unnecessarily forcing me to declare a variable