module Redis::Commands::List
Direct including types
Defined in:
commands/list.crInstance Method Summary
-
#blpop(*keys : String, timeout : Time::Span)
Remove and return an element from the end of the given list.
-
#blpop(*keys : String, timeout : Int | Float)
Remove and return an element from the end of the given list.
-
#blpop(*keys : String, timeout : String)
Remove and return an element from the end of the given list.
- #brpop(keys : Enumerable(String), timeout : Int)
-
#brpop(*keys : String, timeout : Time::Span)
Remove and return an element from the end of the given list.
-
#brpop(*keys : String, timeout : Number)
Remove and return an element from the end of the given list.
-
#brpop(*keys : String, timeout : String)
Remove and return an element from the end of the given list.
- #llen(key : String)
-
#lpop(key : String, count : String | Nil = nil)
Remove an item from the beginning of a list, returning the item or
nil
if the list was empty. - #lpush(key : String, values : Enumerable(String))
-
#lpush(key, *values : String)
Insert an item at the beginning of a list, returning the number of items in the list after the insert.
- #lrange(key : String, start : String, finish : String)
- #lrem(key : String, count : Int, value : String)
-
#rpop(key : String)
Remove and return an element from the end of the given list.
-
#rpoplpush(source : String, destination : String)
Atomically remove an item from the end of a list and insert it at the beginning of another.
-
#rpush(key, *values : String)
Insert an item at the end of a list, returning the number of items in the list after the insert.
Instance Method Detail
Remove and return an element from the end of the given list. If the list
is empty or the key does not exist, this method waits the specified amount
of time for an element to be added to it by another connection. If the
element is added by another connection within that amount of time, this
method will return it immediately. If it is not, then this method returns
nil
.
redis.rpush "foo", "first"
spawn do
sleep 100.milliseconds
redis.rpush "foo", "second"
end
redis.blpop "foo", 1.second # => "first"
redis.blpop "foo", 1.second # => "second" (after 100 milliseconds)
redis.blpop "foo", 1.second # => nil (after 1 second)
Remove and return an element from the end of the given list. If the list
is empty or the key does not exist, this method waits the specified number
of seconds for an element to be added to it by another connection. If the
element is added by another connection within that number of seconds,
this method will return it immediately. If it is not, then this method
returns nil
.
redis.lpush "foo", "first"
spawn do
sleep 100.milliseconds
redis.lpush "foo", "second"
end
redis.blpop "foo", 1 # => "first"
redis.blpop "foo", 1 # => "second" (after 100 milliseconds)
redis.blpop "foo", 1 # => nil (after 1 second)
Remove and return an element from the end of the given list. If the list
is empty or the key does not exist, this method waits the specified number
of seconds for an element to be added to it by another connection. If the
element is added by another connection within that number of seconds,
this method will return it immediately. If it is not, then this method
returns nil
.
redis.lpush "foo", "first"
spawn do
sleep 100.milliseconds
redis.lpush "foo", "second"
end
redis.blpop "foo", "1" # => "first"
redis.blpop "foo", "1" # => "second" (after 100 milliseconds)
redis.blpop "foo", "1" # => nil (after 1 second)
Remove and return an element from the end of the given list. If the list
is empty or the key does not exist, this method waits the specified amount
of time for an element to be added to it by another connection. If the
element is added by another connection within that amount of time, this
method will return it immediately. If it is not, then this method returns
nil
.
redis.lpush "foo", "first"
spawn do
sleep 100.milliseconds
redis.lpush "foo", "second"
end
redis.brpop "foo", 1.second # => "first"
redis.brpop "foo", 1.second # => "second" (after 100 milliseconds)
redis.brpop "foo", 1.second # => nil (after 1 second)
Remove and return an element from the end of the given list. If the list
is empty or the key does not exist, this method waits the specified number
of seconds for an element to be added to it by another connection. If the
element is added by another connection within that number of seconds,
this method will return it immediately. If it is not, then this method
returns nil
.
redis.lpush "foo", "first"
spawn do
sleep 100.milliseconds
redis.lpush "foo", "second"
end
redis.brpop "foo", 1 # => "first"
redis.brpop "foo", 1 # => "second" (after 100 milliseconds)
redis.brpop "foo", 1 # => nil (after 1 second)
Remove and return an element from the end of the given list. If the list
is empty or the key does not exist, this method waits the specified number
of seconds for an element to be added to it by another connection. If the
element is added by another connection within that number of seconds,
this method will return it immediately. If it is not, then this method
returns nil
.
redis.lpush "foo", "first"
spawn do
sleep 100.milliseconds
redis.lpush "foo", "second"
end
redis.brpop "foo", "1" # => "first"
redis.brpop "foo", "1" # => "second" (after 100 milliseconds)
redis.brpop "foo", "1" # => nil (after 1 second)
Remove an item from the beginning of a list, returning the item or nil
if the list was empty.
redis.del "my-list" # Delete so we know it's empty
redis.lpush "my-list", "foo"
redis.lpop "my-list" # => "foo"
redis.lpop "my-list" # => nil
Insert an item at the beginning of a list, returning the number of items in the list after the insert.
redis.del "my-list" # Delete so we know it's empty
redis.lpush "my-list", "foo", "bar" # => 2
redis.lpush "my-list", "foo", "bar" # => 4
Remove and return an element from the end of the given list. If the list
is empty or the key does not exist, this method returns nil
redis.lpush "foo", "hello"
redis.rpop "foo" # => "hello"
redis.rpop "foo" # => nil
Atomically remove an item from the end of a list and insert it at the
beginning of another. Returns that list item. If the first list is empty,
nothing happens and this method returns nil
.
redis.del "foo"
redis.lpush "foo", "hello", "world"
redis.rpoplpush "foo", "bar" # => "hello"
redis.rpoplpush "foo", "bar" # => "world"
redis.rpoplpush "foo", "bar" # => nil
Insert an item at the end of a list, returning the number of items in the list after the insert.
redis.del "my-list" # Delete so we know it's empty
redis.rpush "my-list", "foo", "bar" # => 2
redis.rpush "my-list", "foo", "bar" # => 4