Skip to content

Commit eafdbfa

Browse files
dpevunov-cpclaude
andcommitted
Add GETDEL command support
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ab32297 commit eafdbfa

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/strings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ trait StringCommands[F[_], K, V]
3333

3434
trait Getter[F[_], K, V] {
3535
def get(key: K): F[Option[V]]
36+
def getDel(key: K): F[Option[V]]
3637
def getEx(key: K, getExArg: GetExArg): F[Option[V]]
3738
def getRange(key: K, start: Long, end: Long): F[Option[V]]
3839
def strLen(key: K): F[Long]

modules/effects/src/main/scala/dev/profunktor/redis4cats/redis.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,9 @@ private[redis4cats] class BaseRedis[F[_]: FutureLift: MonadThrow: Log, K, V](
731731
override def get(key: K): F[Option[V]] =
732732
async.flatMap(_.get(key).futureLift.map(Option.apply))
733733

734+
override def getDel(key: K): F[Option[V]] =
735+
async.flatMap(_.getdel(key).futureLift.map(Option.apply))
736+
734737
override def getEx(key: K, getExArg: GetExArg): F[Option[V]] = {
735738
val jgetExArgs = new JGetExArgs()
736739

modules/tests/src/test/scala/dev/profunktor/redis4cats/TestScenarios.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,13 @@ trait TestScenarios { self: FunSuite =>
639639
kttl4 <- redis.ttl("keyToExpire")
640640
_ <- IO(kttl4.nonEmpty)
641641
_ <- redis.del("keyToExpire")
642+
getDelMissing <- redis.getDel("keyToGetDel")
643+
_ <- IO(assert(getDelMissing.isEmpty))
644+
_ <- redis.set("keyToGetDel", "valueToGetDel")
645+
getDelExisting <- redis.getDel("keyToGetDel")
646+
_ <- IO(assert(getDelExisting.contains("valueToGetDel")))
647+
getDelAfter <- redis.get("keyToGetDel")
648+
_ <- IO(assert(getDelAfter.isEmpty))
642649
} yield ()
643650
}
644651

0 commit comments

Comments
 (0)