Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cmd_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,10 @@ func (m *Miniredis) cmdBlmove(c *server.Peer, cmd string, args []string) {
return true
}

var elem string
var (
elem string
ttl = db.ttl[opts.src] // in case we empty the array (deletes the entry)
)
switch opts.srcDir {
case "left":
elem = db.listLpop(opts.src)
Expand All @@ -1042,6 +1045,9 @@ func (m *Miniredis) cmdBlmove(c *server.Peer, cmd string, args []string) {
c.WriteError(msgSyntaxError)
return true
}
if ttl > 0 {
db.ttl[opts.dst] = ttl
}

c.WriteBulk(elem)
return true
Expand Down
7 changes: 7 additions & 0 deletions integration/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,13 @@ func TestBlmove(t *testing.T) {
c.Do("BLMOVE", "round", "round", "RIGHT", "RIGHT", "0")
c.Do("LRANGE", "round", "0", "-1")

// TTL
c.Do("LPUSH", "test", "1")
c.Do("EXPIRE", "test", "1000")
c.Do("TTL", "test")
c.Do("BLMOVE", "test", "test", "LEFT", "LEFT", "1")
c.Do("TTL", "test")

// failure cases
c.Do("RPUSH", "chk", "aap", "noot", "mies")
c.Error("wrong number", "LMOVE")
Expand Down