Skip to content

Commit dd31bf6

Browse files
committed
keep the TTL in BLMOVe
1 parent 958328b commit dd31bf6

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

cmd_list.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,10 @@ func (m *Miniredis) cmdBlmove(c *server.Peer, cmd string, args []string) {
10221022
return true
10231023
}
10241024

1025-
var elem string
1025+
var (
1026+
elem string
1027+
ttl = db.ttl[opts.src] // in case we empty the array (deletes the entry)
1028+
)
10261029
switch opts.srcDir {
10271030
case "left":
10281031
elem = db.listLpop(opts.src)
@@ -1042,6 +1045,9 @@ func (m *Miniredis) cmdBlmove(c *server.Peer, cmd string, args []string) {
10421045
c.WriteError(msgSyntaxError)
10431046
return true
10441047
}
1048+
if ttl > 0 {
1049+
db.ttl[opts.dst] = ttl
1050+
}
10451051

10461052
c.WriteBulk(elem)
10471053
return true

integration/list_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,13 @@ func TestBlmove(t *testing.T) {
628628
c.Do("BLMOVE", "round", "round", "RIGHT", "RIGHT", "0")
629629
c.Do("LRANGE", "round", "0", "-1")
630630

631+
// TTL
632+
c.Do("LPUSH", "test", "1")
633+
c.Do("EXPIRE", "test", "1000")
634+
c.Do("TTL", "test")
635+
c.Do("BLMOVE", "test", "test", "LEFT", "LEFT", "1")
636+
c.Do("TTL", "test")
637+
631638
// failure cases
632639
c.Do("RPUSH", "chk", "aap", "noot", "mies")
633640
c.Error("wrong number", "LMOVE")

0 commit comments

Comments
 (0)