Module: Async::Redis::Methods::Lists

Included in:
Client, Context::Multi
Defined in:
lib/async/redis/methods/lists.rb

Instance Method Summary collapse

Instance Method Details

#blpop(ttl = 0, *keys) ⇒ Object



26
27
28
# File 'lib/async/redis/methods/lists.rb', line 26

def blpop(ttl=0, *keys)
	return call('BLPOP', *keys, ttl)
end

#brpop(ttl = 0, *keys) ⇒ Object



30
31
32
# File 'lib/async/redis/methods/lists.rb', line 30

def brpop(ttl=0, *keys)
	return call('BRPOP', *keys, ttl)
end

#brpoplpush(sorce, destination, timeout) ⇒ Object



34
35
36
# File 'lib/async/redis/methods/lists.rb', line 34

def brpoplpush(sorce, destination, timeout)
	return call('BRPOPLPUSH', source, destination, timeout)
end

#lindex(key, index) ⇒ Object



38
39
40
# File 'lib/async/redis/methods/lists.rb', line 38

def lindex(key, index)
	return call('LINDEX', key, index)
end

#linsert(key, position = :before, index, value) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/async/redis/methods/lists.rb', line 42

def linsert(key, position=:before, index, value)
	if position == :before
		offset = 'BEFORE'
	else
		offset = 'AFTER'
	end

	return call('LINSERT', key, offset, index, value)
end

#llen(key) ⇒ Object



52
53
54
# File 'lib/async/redis/methods/lists.rb', line 52

def llen(key)
	return call('LLEN', key)
end

#lpop(key) ⇒ Object



56
57
58
# File 'lib/async/redis/methods/lists.rb', line 56

def lpop(key)
	return call('LPOP', key)
end

#lpush(key, value, *values) ⇒ Object



60
61
62
63
64
65
66
67
68
69
# File 'lib/async/redis/methods/lists.rb', line 60

def lpush(key, value, *values)
	case value
	when Array
		values = value
	else
		values = [value] + values
	end

	return call('LPUSH', key, *values)
end

#lpushx(key, value) ⇒ Object



71
72
73
# File 'lib/async/redis/methods/lists.rb', line 71

def lpushx(key, value)
	return call('LPUSHX', key, value)
end

#lrange(key, start, stop) ⇒ Object



75
76
77
# File 'lib/async/redis/methods/lists.rb', line 75

def lrange(key, start, stop)
	return call('LRANGE', key, start, stop)
end

#lrem(key, count, value) ⇒ Object



79
80
81
# File 'lib/async/redis/methods/lists.rb', line 79

def lrem(key, count, value)
	return call('LREM', key, count)
end

#lset(key, index, values) ⇒ Object



83
84
85
# File 'lib/async/redis/methods/lists.rb', line 83

def lset(key, index, values)
	return call('LSET', key, index, values)
end

#ltrim(key, start, stop) ⇒ Object



87
88
89
# File 'lib/async/redis/methods/lists.rb', line 87

def ltrim(key, start, stop)
	return call('LTRIM', key, start, stop)
end

#rpop(key) ⇒ Object



91
92
93
# File 'lib/async/redis/methods/lists.rb', line 91

def rpop(key)
	return call('RPOP', key)
end

#rpoplpush(source, destination = nil) ⇒ Object



95
96
97
98
99
# File 'lib/async/redis/methods/lists.rb', line 95

def rpoplpush(source, destination=nil)
	destination = source if destination.nil?

	return call('RPOPLPUSH', source, destination)
end

#rpush(key, value, *values) ⇒ Object



101
102
103
104
105
106
107
108
109
110
# File 'lib/async/redis/methods/lists.rb', line 101

def rpush(key, value, *values)
	case value
	when Array
		values = value
	else
		values = [value] + values
	end

	return call('RPUSH', key, *values)
end

#rpushx(key, value) ⇒ Object



112
113
114
# File 'lib/async/redis/methods/lists.rb', line 112

def rpushx(key, value)
	return call('RPUSHX', key, value)
end