From 60507d0251d2d0fa7da1454924f8f1070e24aa6a Mon Sep 17 00:00:00 2001 From: Odd-Arild Kristensen Date: Thu, 11 Aug 2022 14:48:20 -0600 Subject: [PATCH 1/2] mset() and mget() accept variadic parameters --- .../chrisdavenport/rediculous/RedisCommands.scala | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/src/main/scala/io/chrisdavenport/rediculous/RedisCommands.scala b/core/src/main/scala/io/chrisdavenport/rediculous/RedisCommands.scala index 0736294..51f0183 100644 --- a/core/src/main/scala/io/chrisdavenport/rediculous/RedisCommands.scala +++ b/core/src/main/scala/io/chrisdavenport/rediculous/RedisCommands.scala @@ -696,11 +696,15 @@ object RedisCommands { def expire[F[_]: RedisCtx](key: String, seconds: Long): F[Boolean] = RedisCtx[F].keyed(key, NEL.of("EXPIRE", key.encode, seconds.encode)) - def mget[F[_]: RedisCtx](key: String): F[List[Option[String]]] = { + private[this] def mget[F[_]: RedisCtx](key: String): F[List[Option[String]]] = { val cmd = NEL("MGET", key.encode :: Nil) RedisCtx[F].keyed(key, cmd) } + def mget[F[_]: RedisCtx](key: String, keys: String*): F[List[Option[String]]] = { + RedisCtx[F].keyed(key, NEL("MGET", (key :: keys.toList).map(_.encode))) + } + def bitpos[F[_]: RedisCtx](key: String, bit: Long, start: Long, end: Long): F[Long] = RedisCtx[F].keyed(key, NEL.of("BITPOS", key.encode, bit.encode, start.encode, end.encode)) @@ -769,9 +773,14 @@ object RedisCommands { def hsetnx[F[_]: RedisCtx](key: String, field: String, value: String): F[Boolean] = RedisCtx[F].keyed(key, NEL.of("HSETNX", key.encode, field.encode, value.encode)) - def mset[F[_]: RedisCtx](keyvalue: (String, String)): F[Status] = + private[this] def mset[F[_]: RedisCtx](keyvalue: (String, String)): F[Status] = RedisCtx[F].keyed(keyvalue._1, NEL("MSET", List(keyvalue._1.encode, keyvalue._2.encode))) + def mset[F[_]: RedisCtx](keyValue: (String, String), keyValues: (String, String)*): F[List[Status]] = { + val command = NEL("MSET", (keyValue :: keyValues.toList).flatMap(t => List(t._1.encode, t._2.encode))) + RedisCtx[F].keyed(keyValue._1, command) + } + def setex[F[_]: RedisCtx](key: String, seconds: Long, value: String): F[Status] = RedisCtx[F].keyed(key, NEL.of("SETEX", key.encode, seconds.encode, value.encode)) From 97f1835fc42249b381291d96ef81044f2de44a54 Mon Sep 17 00:00:00 2001 From: Odd-Arild Kristensen Date: Fri, 12 Aug 2022 07:31:47 -0600 Subject: [PATCH 2/2] mset() and mget() are package private --- .../scala/io/chrisdavenport/rediculous/RedisCommands.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/scala/io/chrisdavenport/rediculous/RedisCommands.scala b/core/src/main/scala/io/chrisdavenport/rediculous/RedisCommands.scala index 51f0183..e9cac5d 100644 --- a/core/src/main/scala/io/chrisdavenport/rediculous/RedisCommands.scala +++ b/core/src/main/scala/io/chrisdavenport/rediculous/RedisCommands.scala @@ -696,7 +696,7 @@ object RedisCommands { def expire[F[_]: RedisCtx](key: String, seconds: Long): F[Boolean] = RedisCtx[F].keyed(key, NEL.of("EXPIRE", key.encode, seconds.encode)) - private[this] def mget[F[_]: RedisCtx](key: String): F[List[Option[String]]] = { + private[rediculous] def mget[F[_]: RedisCtx](key: String): F[List[Option[String]]] = { val cmd = NEL("MGET", key.encode :: Nil) RedisCtx[F].keyed(key, cmd) } @@ -773,7 +773,7 @@ object RedisCommands { def hsetnx[F[_]: RedisCtx](key: String, field: String, value: String): F[Boolean] = RedisCtx[F].keyed(key, NEL.of("HSETNX", key.encode, field.encode, value.encode)) - private[this] def mset[F[_]: RedisCtx](keyvalue: (String, String)): F[Status] = + private[rediculous] def mset[F[_]: RedisCtx](keyvalue: (String, String)): F[Status] = RedisCtx[F].keyed(keyvalue._1, NEL("MSET", List(keyvalue._1.encode, keyvalue._2.encode))) def mset[F[_]: RedisCtx](keyValue: (String, String), keyValues: (String, String)*): F[List[Status]] = {