Class: Redis
- Inherits:
-
Object
show all
- Defined in:
- lib/redis.rb,
lib/redis/client.rb,
lib/redis/pipeline.rb,
lib/redis/hash_ring.rb,
lib/redis/subscribe.rb,
lib/redis/distributed.rb
Defined Under Namespace
Classes: Client, CommandOptions, Distributed, HashRing, Pipeline, ProtocolError, SubscribedClient, Subscription
Constant Summary
collapse
- VERSION =
"2.0.3"
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
-
#[](key) ⇒ Object
-
#[]=(key, value) ⇒ Object
-
#append(key, value) ⇒ Object
-
#auth(password) ⇒ Object
-
#bgrewriteaof ⇒ Object
-
#bgsave ⇒ Object
-
#blpop(*args) ⇒ Object
-
#brpop(*args) ⇒ Object
-
#config(action, *args) ⇒ Object
-
#dbsize ⇒ Object
-
#decr(key) ⇒ Object
-
#decrby(key, decrement) ⇒ Object
-
#del(*keys) ⇒ Object
-
#discard ⇒ Object
-
#echo(value) ⇒ Object
-
#exec ⇒ Object
-
#exists(key) ⇒ Object
-
#expire(key, seconds) ⇒ Object
-
#expireat(key, unix_time) ⇒ Object
-
#flushall ⇒ Object
-
#flushdb ⇒ Object
-
#get(key) ⇒ Object
-
#getset(key, value) ⇒ Object
-
#hdel(key, field) ⇒ Object
-
#hexists(key, field) ⇒ Object
-
#hget(key, field) ⇒ Object
-
#hgetall(key) ⇒ Object
-
#hincrby(key, field, increment) ⇒ Object
-
#hkeys(key) ⇒ Object
-
#hlen(key) ⇒ Object
-
#hmget(key, *fields) ⇒ Object
-
#hmset(key, *attrs) ⇒ Object
-
#hset(key, field, value) ⇒ Object
-
#hvals(key) ⇒ Object
-
#id ⇒ Object
-
#incr(key) ⇒ Object
-
#incrby(key, increment) ⇒ Object
-
#info ⇒ Object
-
#initialize(options = {}) ⇒ Redis
constructor
-
#inspect ⇒ Object
-
#keys(pattern = "*") ⇒ Object
-
#lastsave ⇒ Object
-
#lindex(key, index) ⇒ Object
-
#llen(key) ⇒ Object
-
#lpop(key) ⇒ Object
-
#lpush(key, value) ⇒ Object
-
#lrange(key, start, stop) ⇒ Object
-
#lrem(key, count, value) ⇒ Object
-
#lset(key, index, value) ⇒ Object
-
#ltrim(key, start, stop) ⇒ Object
-
#mapped_hmget(key, *fields) ⇒ Object
-
#mapped_hmset(key, hash) ⇒ Object
-
#mapped_mget(*keys) ⇒ Object
-
#mapped_mset(hash) ⇒ Object
-
#mapped_msetnx(hash) ⇒ Object
-
#method_missing(command, *args) ⇒ Object
-
#mget(*keys) ⇒ Object
-
#monitor(&block) ⇒ Object
-
#move(key, db) ⇒ Object
-
#mset(*args) ⇒ Object
-
#msetnx(*args) ⇒ Object
-
#multi(&block) ⇒ Object
-
#ping ⇒ Object
-
#pipelined ⇒ Object
-
#psubscribe(*channels, &block) ⇒ Object
-
#publish(channel, message) ⇒ Object
-
#punsubscribe(*channels) ⇒ Object
-
#quit ⇒ Object
-
#randomkey ⇒ Object
-
#rename(old_name, new_name) ⇒ Object
-
#renamenx(old_name, new_name) ⇒ Object
-
#rpop(key) ⇒ Object
-
#rpoplpush(source, destination) ⇒ Object
-
#rpush(key, value) ⇒ Object
-
#sadd(key, value) ⇒ Object
-
#save ⇒ Object
-
#scard(key) ⇒ Object
-
#sdiff(*keys) ⇒ Object
-
#sdiffstore(destination, *keys) ⇒ Object
-
#select(db) ⇒ Object
-
#set(key, value) ⇒ Object
-
#setex(key, ttl, value) ⇒ Object
-
#setnx(key, value) ⇒ Object
-
#shutdown ⇒ Object
-
#sinter(*keys) ⇒ Object
-
#sinterstore(destination, *keys) ⇒ Object
-
#sismember(key, member) ⇒ Object
-
#slaveof(host, port) ⇒ Object
-
#smembers(key) ⇒ Object
-
#smove(source, destination, member) ⇒ Object
-
#sort(key, options = {}) ⇒ Object
-
#spop(key) ⇒ Object
-
#srandmember(key) ⇒ Object
-
#srem(key, value) ⇒ Object
-
#subscribe(*channels, &block) ⇒ Object
-
#subscribed? ⇒ Boolean
-
#substr(key, start, stop) ⇒ Object
-
#sunion(*keys) ⇒ Object
-
#sunionstore(destination, *keys) ⇒ Object
-
#ttl(key) ⇒ Object
-
#type(key) ⇒ Object
-
#unsubscribe(*channels) ⇒ Object
-
#unwatch ⇒ Object
-
#watch(*keys) ⇒ Object
-
#zadd(key, score, member) ⇒ Object
-
#zcard(key) ⇒ Object
-
#zincrby(key, increment, member) ⇒ Object
-
#zinterstore(destination, keys, options = {}) ⇒ Object
-
#zrange(key, start, stop, options = {}) ⇒ Object
-
#zrangebyscore(key, min, max, options = {}) ⇒ Object
-
#zrank(key, member) ⇒ Object
-
#zrem(key, member) ⇒ Object
-
#zremrangebyrank(key, start, stop) ⇒ Object
-
#zremrangebyscore(key, min, max) ⇒ Object
-
#zrevrange(key, start, stop, options = {}) ⇒ Object
-
#zrevrank(key, member) ⇒ Object
-
#zscore(key, member) ⇒ Object
-
#zunionstore(destination, keys, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Redis
Returns a new instance of Redis.
31
32
33
34
35
36
37
|
# File 'lib/redis.rb', line 31
def initialize(options = {})
if options[:thread_safe]
@client = Client::ThreadSafe.new(options)
else
@client = Client.new(options)
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(command, *args) ⇒ Object
557
558
559
|
# File 'lib/redis.rb', line 557
def method_missing(command, *args)
@client.call(command, *args)
end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
16
17
18
|
# File 'lib/redis.rb', line 16
def client
@client
end
|
Class Method Details
.connect(options = {}) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/redis.rb', line 18
def self.connect(options = {})
require "uri"
url = URI(options.delete(:url) || ENV["REDIS_URL"] || "redis://127.0.0.1:6379/0")
options[:host] = url.host
options[:port] = url.port
options[:password] = url.password
options[:db] = url.path[1..-1].to_i
new(options)
end
|
.deprecate(message, trace = caller[0]) ⇒ Object
12
13
14
|
# File 'lib/redis.rb', line 12
def self.deprecate(message, trace = caller[0])
$stderr.puts "\n#{message} (in #{trace})"
end
|
Instance Method Details
#[](key) ⇒ Object
405
406
407
|
# File 'lib/redis.rb', line 405
def [](key)
get(key)
end
|
#[]=(key, value) ⇒ Object
409
410
411
|
# File 'lib/redis.rb', line 409
def []=(key,value)
set(key, value)
end
|
#append(key, value) ⇒ Object
90
91
92
|
# File 'lib/redis.rb', line 90
def append(key, value)
@client.call(:append, key, value)
end
|
#auth(password) ⇒ Object
39
40
41
|
# File 'lib/redis.rb', line 39
def auth(password)
@client.call(:auth, password)
end
|
#bgrewriteaof ⇒ Object
74
75
76
|
# File 'lib/redis.rb', line 74
def bgrewriteaof
@client.call(:bgrewriteaof)
end
|
#bgsave ⇒ Object
70
71
72
|
# File 'lib/redis.rb', line 70
def bgsave
@client.call(:bgsave)
end
|
#blpop(*args) ⇒ Object
178
179
180
|
# File 'lib/redis.rb', line 178
def blpop(*args)
@client.call_without_timeout(:blpop, *args)
end
|
#brpop(*args) ⇒ Object
182
183
184
|
# File 'lib/redis.rb', line 182
def brpop(*args)
@client.call_without_timeout(:brpop, *args)
end
|
#config(action, *args) ⇒ Object
52
53
54
55
56
|
# File 'lib/redis.rb', line 52
def config(action, *args)
response = @client.call(:config, action, *args)
response = Hash[*response] if action == :get
response
end
|
#dbsize ⇒ Object
134
135
136
|
# File 'lib/redis.rb', line 134
def dbsize
@client.call(:dbsize)
end
|
#decr(key) ⇒ Object
461
462
463
|
# File 'lib/redis.rb', line 461
def decr(key)
@client.call(:decr, key)
end
|
#decrby(key, decrement) ⇒ Object
465
466
467
|
# File 'lib/redis.rb', line 465
def decrby(key, decrement)
@client.call(:decrby, key, decrement)
end
|
#del(*keys) ⇒ Object
337
338
339
|
# File 'lib/redis.rb', line 337
def del(*keys)
_bool @client.call(:del, *keys)
end
|
#discard ⇒ Object
393
394
395
|
# File 'lib/redis.rb', line 393
def discard
@client.call(:discard)
end
|
#echo(value) ⇒ Object
122
123
124
|
# File 'lib/redis.rb', line 122
def echo(value)
@client.call(:echo, value)
end
|
#exec ⇒ Object
504
505
506
|
# File 'lib/redis.rb', line 504
def exec
@client.call(:exec)
end
|
#exists(key) ⇒ Object
138
139
140
|
# File 'lib/redis.rb', line 138
def exists(key)
_bool @client.call(:exists, key)
end
|
#expire(key, seconds) ⇒ Object
349
350
351
|
# File 'lib/redis.rb', line 349
def expire(key, seconds)
_bool @client.call(:expire, key, seconds)
end
|
#expireat(key, unix_time) ⇒ Object
357
358
359
|
# File 'lib/redis.rb', line 357
def expireat(key, unix_time)
_bool @client.call(:expireat, key, unix_time)
end
|
#flushall ⇒ Object
62
63
64
|
# File 'lib/redis.rb', line 62
def flushall
@client.call(:flushall)
end
|
#flushdb ⇒ Object
58
59
60
|
# File 'lib/redis.rb', line 58
def flushdb
@client.call(:flushdb)
end
|
#get(key) ⇒ Object
78
79
80
|
# File 'lib/redis.rb', line 78
def get(key)
@client.call(:get, key)
end
|
#getset(key, value) ⇒ Object
82
83
84
|
# File 'lib/redis.rb', line 82
def getset(key, value)
@client.call(:getset, key, value)
end
|
#hdel(key, field) ⇒ Object
106
107
108
|
# File 'lib/redis.rb', line 106
def hdel(key, field)
@client.call(:hdel, key, field)
end
|
#hexists(key, field) ⇒ Object
397
398
399
|
# File 'lib/redis.rb', line 397
def hexists(key, field)
_bool @client.call(:hexists, key, field)
end
|
#hget(key, field) ⇒ Object
102
103
104
|
# File 'lib/redis.rb', line 102
def hget(key, field)
@client.call(:hget, key, field)
end
|
#hgetall(key) ⇒ Object
98
99
100
|
# File 'lib/redis.rb', line 98
def hgetall(key)
Hash[*@client.call(:hgetall, key)]
end
|
#hincrby(key, field, increment) ⇒ Object
389
390
391
|
# File 'lib/redis.rb', line 389
def hincrby(key, field, increment)
@client.call(:hincrby, key, field, increment)
end
|
#hkeys(key) ⇒ Object
110
111
112
|
# File 'lib/redis.rb', line 110
def hkeys(key)
@client.call(:hkeys, key)
end
|
#hlen(key) ⇒ Object
381
382
383
|
# File 'lib/redis.rb', line 381
def hlen(key)
@client.call(:hlen, key)
end
|
#hmget(key, *fields) ⇒ Object
373
374
375
|
# File 'lib/redis.rb', line 373
def hmget(key, *fields)
@client.call(:hmget, key, *fields)
end
|
#hmset(key, *attrs) ⇒ Object
365
366
367
|
# File 'lib/redis.rb', line 365
def hmset(key, *attrs)
@client.call(:hmset, key, *attrs)
end
|
#hset(key, field, value) ⇒ Object
361
362
363
|
# File 'lib/redis.rb', line 361
def hset(key, field, value)
_bool @client.call(:hset, key, field, value)
end
|
#hvals(key) ⇒ Object
385
386
387
|
# File 'lib/redis.rb', line 385
def hvals(key)
@client.call(:hvals, key)
end
|
#id ⇒ Object
549
550
551
|
# File 'lib/redis.rb', line 549
def id
@client.id
end
|
#incr(key) ⇒ Object
453
454
455
|
# File 'lib/redis.rb', line 453
def incr(key)
@client.call(:incr, key)
end
|
#incrby(key, increment) ⇒ Object
457
458
459
|
# File 'lib/redis.rb', line 457
def incrby(key, increment)
@client.call(:incrby, key, increment)
end
|
#info ⇒ Object
48
49
50
|
# File 'lib/redis.rb', line 48
def info
Hash[*@client.call(:info).split(/:|\r\n/)]
end
|
#inspect ⇒ Object
553
554
555
|
# File 'lib/redis.rb', line 553
def inspect
"#<Redis client v#{Redis::VERSION} connected to #{id} (Redis v#{info["redis_version"]})>"
end
|
#keys(pattern = "*") ⇒ Object
114
115
116
|
# File 'lib/redis.rb', line 114
def keys(pattern = "*")
_array @client.call(:keys, pattern)
end
|
#lastsave ⇒ Object
130
131
132
|
# File 'lib/redis.rb', line 130
def lastsave
@client.call(:lastsave)
end
|
#lindex(key, index) ⇒ Object
154
155
156
|
# File 'lib/redis.rb', line 154
def lindex(key, index)
@client.call(:lindex, key, index)
end
|
#llen(key) ⇒ Object
142
143
144
|
# File 'lib/redis.rb', line 142
def llen(key)
@client.call(:llen, key)
end
|
#lpop(key) ⇒ Object
190
191
192
|
# File 'lib/redis.rb', line 190
def lpop(key)
@client.call(:lpop, key)
end
|
#lpush(key, value) ⇒ Object
170
171
172
|
# File 'lib/redis.rb', line 170
def lpush(key, value)
@client.call(:lpush, key, value)
end
|
#lrange(key, start, stop) ⇒ Object
146
147
148
|
# File 'lib/redis.rb', line 146
def lrange(key, start, stop)
@client.call(:lrange, key, start, stop)
end
|
#lrem(key, count, value) ⇒ Object
162
163
164
|
# File 'lib/redis.rb', line 162
def lrem(key, count, value)
@client.call(:lrem, key, count, value)
end
|
#lset(key, index, value) ⇒ Object
158
159
160
|
# File 'lib/redis.rb', line 158
def lset(key, index, value)
@client.call(:lset, key, index, value)
end
|
#ltrim(key, start, stop) ⇒ Object
150
151
152
|
# File 'lib/redis.rb', line 150
def ltrim(key, start, stop)
@client.call(:ltrim, key, start, stop)
end
|
#mapped_hmget(key, *fields) ⇒ Object
377
378
379
|
# File 'lib/redis.rb', line 377
def mapped_hmget(key, *fields)
Hash[*fields.zip(hmget(key, *fields)).flatten]
end
|
#mapped_hmset(key, hash) ⇒ Object
369
370
371
|
# File 'lib/redis.rb', line 369
def mapped_hmset(key, hash)
hmset(key, *hash.to_a.flatten)
end
|
#mapped_mget(*keys) ⇒ Object
437
438
439
|
# File 'lib/redis.rb', line 437
def mapped_mget(*keys)
Hash[*keys.zip(mget(*keys)).flatten]
end
|
#mapped_mset(hash) ⇒ Object
425
426
427
|
# File 'lib/redis.rb', line 425
def mapped_mset(hash)
mset(*hash.to_a.flatten)
end
|
#mapped_msetnx(hash) ⇒ Object
433
434
435
|
# File 'lib/redis.rb', line 433
def mapped_msetnx(hash)
msetnx(*hash.to_a.flatten)
end
|
#mget(*keys) ⇒ Object
86
87
88
|
# File 'lib/redis.rb', line 86
def mget(*keys)
@client.call(:mget, *keys)
end
|
#monitor(&block) ⇒ Object
401
402
403
|
# File 'lib/redis.rb', line 401
def monitor(&block)
@client.call_loop(:monitor, &block)
end
|
#move(key, db) ⇒ Object
329
330
331
|
# File 'lib/redis.rb', line 329
def move(key, db)
_bool @client.call(:move, key, db)
end
|
#mset(*args) ⇒ Object
421
422
423
|
# File 'lib/redis.rb', line 421
def mset(*args)
@client.call(:mset, *args)
end
|
#msetnx(*args) ⇒ Object
429
430
431
|
# File 'lib/redis.rb', line 429
def msetnx(*args)
@client.call(:msetnx, *args)
end
|
#multi(&block) ⇒ Object
508
509
510
511
512
513
514
515
516
517
518
519
520
521
|
# File 'lib/redis.rb', line 508
def multi(&block)
result = @client.call :multi
return result unless block_given?
begin
yield(self)
rescue Exception => e
discard
raise e
end
exec
end
|
#ping ⇒ Object
126
127
128
|
# File 'lib/redis.rb', line 126
def ping
@client.call(:ping)
end
|
#pipelined ⇒ Object
488
489
490
491
492
493
494
|
# File 'lib/redis.rb', line 488
def pipelined
original, @client = @client, Pipeline.new
yield
original.call_pipelined(@client.commands) unless @client.commands.empty?
ensure
@client = original
end
|
#psubscribe(*channels, &block) ⇒ Object
545
546
547
|
# File 'lib/redis.rb', line 545
def psubscribe(*channels, &block)
subscription(:psubscribe, channels, block)
end
|
#publish(channel, message) ⇒ Object
523
524
525
|
# File 'lib/redis.rb', line 523
def publish(channel, message)
@client.call(:publish, channel, message)
end
|
#punsubscribe(*channels) ⇒ Object
536
537
538
539
|
# File 'lib/redis.rb', line 536
def punsubscribe(*channels)
raise RuntimeError, "Can't unsubscribe if not subscribed." unless subscribed?
@client.punsubscribe(*channels)
end
|
#quit ⇒ Object
473
474
475
476
477
478
|
# File 'lib/redis.rb', line 473
def quit
@client.call(:quit)
rescue Errno::ECONNRESET
ensure
@client.disconnect
end
|
#randomkey ⇒ Object
118
119
120
|
# File 'lib/redis.rb', line 118
def randomkey
@client.call(:randomkey)
end
|
#rename(old_name, new_name) ⇒ Object
341
342
343
|
# File 'lib/redis.rb', line 341
def rename(old_name, new_name)
@client.call(:rename, old_name, new_name)
end
|
#renamenx(old_name, new_name) ⇒ Object
345
346
347
|
# File 'lib/redis.rb', line 345
def renamenx(old_name, new_name)
_bool @client.call(:renamenx, old_name, new_name)
end
|
#rpop(key) ⇒ Object
174
175
176
|
# File 'lib/redis.rb', line 174
def rpop(key)
@client.call(:rpop, key)
end
|
#rpoplpush(source, destination) ⇒ Object
186
187
188
|
# File 'lib/redis.rb', line 186
def rpoplpush(source, destination)
@client.call(:rpoplpush, source, destination)
end
|
#rpush(key, value) ⇒ Object
166
167
168
|
# File 'lib/redis.rb', line 166
def rpush(key, value)
@client.call(:rpush, key, value)
end
|
#sadd(key, value) ⇒ Object
202
203
204
|
# File 'lib/redis.rb', line 202
def sadd(key, value)
_bool @client.call(:sadd, key, value)
end
|
#save ⇒ Object
66
67
68
|
# File 'lib/redis.rb', line 66
def save
@client.call(:save)
end
|
#scard(key) ⇒ Object
218
219
220
|
# File 'lib/redis.rb', line 218
def scard(key)
@client.call(:scard, key)
end
|
#sdiff(*keys) ⇒ Object
238
239
240
|
# File 'lib/redis.rb', line 238
def sdiff(*keys)
@client.call(:sdiff, *keys)
end
|
#sdiffstore(destination, *keys) ⇒ Object
242
243
244
|
# File 'lib/redis.rb', line 242
def sdiffstore(destination, *keys)
@client.call(:sdiffstore, destination, *keys)
end
|
#select(db) ⇒ Object
43
44
45
46
|
# File 'lib/redis.rb', line 43
def select(db)
@client.db = db
@client.call(:select, db)
end
|
#set(key, value) ⇒ Object
413
414
415
|
# File 'lib/redis.rb', line 413
def set(key, value)
@client.call(:set, key, value)
end
|
#setex(key, ttl, value) ⇒ Object
417
418
419
|
# File 'lib/redis.rb', line 417
def setex(key, ttl, value)
@client.call(:setex, key, ttl, value)
end
|
#setnx(key, value) ⇒ Object
333
334
335
|
# File 'lib/redis.rb', line 333
def setnx(key, value)
_bool @client.call(:setnx, key, value)
end
|
#shutdown ⇒ Object
480
481
482
|
# File 'lib/redis.rb', line 480
def shutdown
@client.call(:shutdown)
end
|
#sinter(*keys) ⇒ Object
222
223
224
|
# File 'lib/redis.rb', line 222
def sinter(*keys)
@client.call(:sinter, *keys)
end
|
#sinterstore(destination, *keys) ⇒ Object
226
227
228
|
# File 'lib/redis.rb', line 226
def sinterstore(destination, *keys)
@client.call(:sinterstore, destination, *keys)
end
|
#sismember(key, member) ⇒ Object
198
199
200
|
# File 'lib/redis.rb', line 198
def sismember(key, member)
_bool @client.call(:sismember, key, member)
end
|
#slaveof(host, port) ⇒ Object
484
485
486
|
# File 'lib/redis.rb', line 484
def slaveof(host, port)
@client.call(:slaveof, host, port)
end
|
#smembers(key) ⇒ Object
194
195
196
|
# File 'lib/redis.rb', line 194
def smembers(key)
@client.call(:smembers, key)
end
|
#smove(source, destination, member) ⇒ Object
210
211
212
|
# File 'lib/redis.rb', line 210
def smove(source, destination, member)
_bool @client.call(:smove, source, destination, member)
end
|
#sort(key, options = {}) ⇒ Object
441
442
443
444
445
446
447
448
449
450
451
|
# File 'lib/redis.rb', line 441
def sort(key, options = {})
command = CommandOptions.new(options) do |c|
c.value :by
c.splat :limit
c.multi :get
c.words :order
c.value :store
end
@client.call(:sort, key, *command.to_a)
end
|
#spop(key) ⇒ Object
214
215
216
|
# File 'lib/redis.rb', line 214
def spop(key)
@client.call(:spop, key)
end
|
#srandmember(key) ⇒ Object
246
247
248
|
# File 'lib/redis.rb', line 246
def srandmember(key)
@client.call(:srandmember, key)
end
|
#srem(key, value) ⇒ Object
206
207
208
|
# File 'lib/redis.rb', line 206
def srem(key, value)
_bool @client.call(:srem, key, value)
end
|
#subscribe(*channels, &block) ⇒ Object
541
542
543
|
# File 'lib/redis.rb', line 541
def subscribe(*channels, &block)
subscription(:subscribe, channels, block)
end
|
#subscribed? ⇒ Boolean
527
528
529
|
# File 'lib/redis.rb', line 527
def subscribed?
@client.kind_of? SubscribedClient
end
|
#substr(key, start, stop) ⇒ Object
94
95
96
|
# File 'lib/redis.rb', line 94
def substr(key, start, stop)
@client.call(:substr, key, start, stop)
end
|
#sunion(*keys) ⇒ Object
230
231
232
|
# File 'lib/redis.rb', line 230
def sunion(*keys)
@client.call(:sunion, *keys)
end
|
#sunionstore(destination, *keys) ⇒ Object
234
235
236
|
# File 'lib/redis.rb', line 234
def sunionstore(destination, *keys)
@client.call(:sunionstore, destination, *keys)
end
|
#ttl(key) ⇒ Object
353
354
355
|
# File 'lib/redis.rb', line 353
def ttl(key)
@client.call(:ttl, key)
end
|
#type(key) ⇒ Object
469
470
471
|
# File 'lib/redis.rb', line 469
def type(key)
@client.call(:type, key)
end
|
#unsubscribe(*channels) ⇒ Object
531
532
533
534
|
# File 'lib/redis.rb', line 531
def unsubscribe(*channels)
raise RuntimeError, "Can't unsubscribe if not subscribed." unless subscribed?
@client.unsubscribe(*channels)
end
|
#unwatch ⇒ Object
500
501
502
|
# File 'lib/redis.rb', line 500
def unwatch
@client.call(:unwatch)
end
|
#watch(*keys) ⇒ Object
496
497
498
|
# File 'lib/redis.rb', line 496
def watch(*keys)
@client.call(:watch, *keys)
end
|
#zadd(key, score, member) ⇒ Object
250
251
252
|
# File 'lib/redis.rb', line 250
def zadd(key, score, member)
_bool @client.call(:zadd, key, score, member)
end
|
#zcard(key) ⇒ Object
266
267
268
|
# File 'lib/redis.rb', line 266
def zcard(key)
@client.call(:zcard, key)
end
|
#zincrby(key, increment, member) ⇒ Object
262
263
264
|
# File 'lib/redis.rb', line 262
def zincrby(key, increment, member)
@client.call(:zincrby, key, increment, member)
end
|
#zinterstore(destination, keys, options = {}) ⇒ Object
311
312
313
314
315
316
317
318
|
# File 'lib/redis.rb', line 311
def zinterstore(destination, keys, options = {})
command = CommandOptions.new(options) do |c|
c.splat :weights
c.value :aggregate
end
@client.call(:zinterstore, destination, keys.size, *(keys + command.to_a))
end
|
#zrange(key, start, stop, options = {}) ⇒ Object
270
271
272
273
274
275
276
|
# File 'lib/redis.rb', line 270
def zrange(key, start, stop, options = {})
command = CommandOptions.new(options) do |c|
c.bool :with_scores
end
@client.call(:zrange, key, start, stop, *command.to_a)
end
|
#zrangebyscore(key, min, max, options = {}) ⇒ Object
278
279
280
281
282
283
284
285
|
# File 'lib/redis.rb', line 278
def zrangebyscore(key, min, max, options = {})
command = CommandOptions.new(options) do |c|
c.splat :limit
c.bool :with_scores
end
@client.call(:zrangebyscore, key, min, max, *command.to_a)
end
|
#zrank(key, member) ⇒ Object
254
255
256
|
# File 'lib/redis.rb', line 254
def zrank(key, member)
@client.call(:zrank, key, member)
end
|
#zrem(key, member) ⇒ Object
307
308
309
|
# File 'lib/redis.rb', line 307
def zrem(key, member)
_bool @client.call(:zrem, key, member)
end
|
#zremrangebyrank(key, start, stop) ⇒ Object
299
300
301
|
# File 'lib/redis.rb', line 299
def zremrangebyrank(key, start, stop)
@client.call(:zremrangebyrank, key, start, stop)
end
|
#zremrangebyscore(key, min, max) ⇒ Object
295
296
297
|
# File 'lib/redis.rb', line 295
def zremrangebyscore(key, min, max)
@client.call(:zremrangebyscore, key, min, max)
end
|
#zrevrange(key, start, stop, options = {}) ⇒ Object
287
288
289
290
291
292
293
|
# File 'lib/redis.rb', line 287
def zrevrange(key, start, stop, options = {})
command = CommandOptions.new(options) do |c|
c.bool :with_scores
end
@client.call(:zrevrange, key, start, stop, *command.to_a)
end
|
#zrevrank(key, member) ⇒ Object
258
259
260
|
# File 'lib/redis.rb', line 258
def zrevrank(key, member)
@client.call(:zrevrank, key, member)
end
|
#zscore(key, member) ⇒ Object
303
304
305
|
# File 'lib/redis.rb', line 303
def zscore(key, member)
@client.call(:zscore, key, member)
end
|
#zunionstore(destination, keys, options = {}) ⇒ Object
320
321
322
323
324
325
326
327
|
# File 'lib/redis.rb', line 320
def zunionstore(destination, keys, options = {})
command = CommandOptions.new(options) do |c|
c.splat :weights
c.value :aggregate
end
@client.call(:zunionstore, destination, keys.size, *(keys + command.to_a))
end
|