Module: RedisCluster::Function::List
- Included in:
- RedisCluster::Function
- Defined in:
- lib/redis_cluster/function/list.rb
Overview
List implement redis lists commands. There will be some adjustment for cluster. see redis.io/commands#list. Most of the code are copied from github.com/redis/redis-rb/blob/master/lib/redis.rb.
SETTER = [:linsert, :lpop, :lpush, :lpushx, :lrem, :lset, :ltrim, :rpop, :rpush, :rpushx] GETTER = [:lindex, :llen, :lrange]
Instance Method Summary collapse
-
#lindex(key, index) ⇒ String
Get an element from a list by its index.
-
#linsert(key, where, pivot, value) ⇒ Fixnum
Insert an element before or after another element in a list.
-
#llen(key) ⇒ Fixnum
Get the length of a list.
-
#lpop(key) ⇒ String
Remove and get the first element in a list.
-
#lpush(key, value) ⇒ Fixnum
Prepend one or more values to a list, creating the list if it doesn’t exist.
-
#lpushx(key, value) ⇒ Fixnum
Prepend a value to a list, only if the list exists.
-
#lrange(key, start, stop) ⇒ Array<String>
Get a range of elements from a list.
-
#lrem(key, count, value) ⇒ Fixnum
Remove elements from a list.
-
#lset(key, index, value) ⇒ String
Set the value of an element in a list by its index.
-
#ltrim(key, start, stop) ⇒ String
Trim a list to the specified range.
-
#rpop(key) ⇒ String
Remove and get the last element in a list.
-
#rpush(key, value) ⇒ Fixnum
Append one or more values to a list, creating the list if it doesn’t exist.
-
#rpushx(key, value) ⇒ Fixnum
Append a value to a list, only if the list exists.
Instance Method Details
#lindex(key, index) ⇒ String
Get an element from a list by its index.
79 80 81 |
# File 'lib/redis_cluster/function/list.rb', line 79 def lindex(key, index) call(key, [:lindex, key, index], read: true) end |
#linsert(key, where, pivot, value) ⇒ Fixnum
Insert an element before or after another element in a list.
91 92 93 |
# File 'lib/redis_cluster/function/list.rb', line 91 def linsert(key, where, pivot, value) call(key, [:linsert, key, where, pivot, value]) end |
#llen(key) ⇒ Fixnum
Get the length of a list.
18 19 20 |
# File 'lib/redis_cluster/function/list.rb', line 18 def llen(key) call(key, [:llen, key], read: true) end |
#lpop(key) ⇒ String
Remove and get the first element in a list.
62 63 64 |
# File 'lib/redis_cluster/function/list.rb', line 62 def lpop(key) call(key, [:lpop, key]) end |
#lpush(key, value) ⇒ Fixnum
Prepend one or more values to a list, creating the list if it doesn’t exist
27 28 29 |
# File 'lib/redis_cluster/function/list.rb', line 27 def lpush(key, value) call(key, [:lpush, key, value]) end |
#lpushx(key, value) ⇒ Fixnum
Prepend a value to a list, only if the list exists.
36 37 38 |
# File 'lib/redis_cluster/function/list.rb', line 36 def lpushx(key, value) call(key, [:lpushx, key, value]) end |
#lrange(key, start, stop) ⇒ Array<String>
Get a range of elements from a list.
101 102 103 |
# File 'lib/redis_cluster/function/list.rb', line 101 def lrange(key, start, stop) call(key, [:lrange, key, start, stop], read: true) end |
#lrem(key, count, value) ⇒ Fixnum
Remove elements from a list.
114 115 116 |
# File 'lib/redis_cluster/function/list.rb', line 114 def lrem(key, count, value) call(key, [:lrem, key, count, value]) end |
#lset(key, index, value) ⇒ String
Set the value of an element in a list by its index.
124 125 126 |
# File 'lib/redis_cluster/function/list.rb', line 124 def lset(key, index, value) call(key, [:lset, key, index, value]) end |
#ltrim(key, start, stop) ⇒ String
Trim a list to the specified range.
134 135 136 |
# File 'lib/redis_cluster/function/list.rb', line 134 def ltrim(key, start, stop) call(key, [:ltrim, key, start, stop]) end |
#rpop(key) ⇒ String
Remove and get the last element in a list.
70 71 72 |
# File 'lib/redis_cluster/function/list.rb', line 70 def rpop(key) call(key, [:rpop, key]) end |
#rpush(key, value) ⇒ Fixnum
Append one or more values to a list, creating the list if it doesn’t exist
45 46 47 |
# File 'lib/redis_cluster/function/list.rb', line 45 def rpush(key, value) call(key, [:rpush, key, value]) end |
#rpushx(key, value) ⇒ Fixnum
Append a value to a list, only if the list exists.
54 55 56 |
# File 'lib/redis_cluster/function/list.rb', line 54 def rpushx(key, value) call(key, [:rpushx, key, value]) end |