Interfector
Interfector

Reputation: 1898

Mass insert using rediscala

I am trying to prepare a mass insert using https://github.com/etaty/rediscala version 1.2 without any success. Best way that I figured was to make something like this:

implicit val akkaSystem = akka.actor.ActorSystem()

val redis = RedisClient()

RedisProtocolRequest.multiBulk("SET", Seq(ByteString("mykey"), ByteString("myvalue")) ) ++ RedisProtocolRequest.multiBulk("SET", Seq(ByteString("yourkey"), ByteString("yourvalue")) )

???????????

akkaSystem.shutdown()

Unfortunetly, I was not able to find a method to send a ByteString to the server. Can someone help me finish the script, or am I on the wrong path?

Upvotes: 1

Views: 550

Answers (1)

Aivaras
Aivaras

Reputation: 439

Why not use redis.transaction?

val keys = Seq("mykey", "yourkey")
val values = Seq("myvalue", "yourvalue")

val multi = redis.transaction()
keys.zip(values).foreach(p => {
  multi.set(p._1, p._2)
})
val futureResponse = multi.exec()

Upvotes: 2

Related Questions