Class: RedisObj::SortedSet
- Inherits:
-
Base
- Object
- Base
- RedisObj::SortedSet
show all
- Defined in:
- lib/redis_obj/sorted_set.rb
Instance Attribute Summary
Attributes inherited from Base
#key, #redis
Instance Method Summary
collapse
-
#card(min = nil, max = nil) ⇒ Object
(also: #length, #size, #zcount)
-
#dec(member) ⇒ Object
(also: #decr)
-
#inc(member) ⇒ Object
(also: #incr)
-
#method_missing(method, *arguments, &blk) ⇒ Object
Allow for non prefixed versions of the commands to be sent as well as making future proof for new versions of redis.
-
#respond_to_missing?(method, include_private = false) ⇒ Boolean
-
#zincrby(amt, member) ⇒ Object
(also: #incby)
-
#zinterstore(destination, keys, options = {}, &blk) ⇒ Object
-
#zremrangebyrank(start, stop = nil) ⇒ Object
-
#zremrangebyscore(start, stop = nil) ⇒ Object
-
#zunionstore(destination, keys, options = {}, &blk) ⇒ Object
Methods inherited from Base
#==, #clear, #del_key, #get_keys, #initialize
Constructor Details
This class inherits a constructor from RedisObj::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *arguments, &blk) ⇒ Object
Allow for non prefixed versions of the commands to be sent as well as making future proof for new versions of redis
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/redis_obj/sorted_set.rb', line 61
def method_missing method, *arguments, &blk
if redis.respond_to?(method)
redis.__send__(method,key,*arguments,&blk)
else
if method.to_s[0] != 'z' && (new_method = "z#{method}") && redis.respond_to?(new_method)
self.send(new_method,*arguments,&blk)
else
super
end
end
end
|
Instance Method Details
#card(min = nil, max = nil) ⇒ Object
Also known as:
length, size, zcount
2
3
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/redis_obj/sorted_set.rb', line 2
def card min=nil,max=nil
if min
if min.respond_to?(:max) && min.respond_to?(:min)
max = min.max
min = min.min
end
redis.zcount(key,min,max)
else
redis.zcard(key)
end
end
|
#dec(member) ⇒ Object
Also known as:
decr
28
29
30
|
# File 'lib/redis_obj/sorted_set.rb', line 28
def dec member
incrby(-1,member)
end
|
#inc(member) ⇒ Object
Also known as:
incr
23
24
25
|
# File 'lib/redis_obj/sorted_set.rb', line 23
def inc member
incrby(1,member)
end
|
#respond_to_missing?(method, include_private = false) ⇒ Boolean
76
77
78
79
80
|
# File 'lib/redis_obj/sorted_set.rb', line 76
def respond_to_missing?(method, include_private = false)
return true if redis.respond_to?(method)
method = method.to_s
method[0] != 'z' && redis.respond_to?("z#{method}") or super
end
|
#zincrby(amt, member) ⇒ Object
Also known as:
incby
18
19
20
|
# File 'lib/redis_obj/sorted_set.rb', line 18
def zincrby amt, member
redis.zincby(key,amt,member)
end
|
#zinterstore(destination, keys, options = {}, &blk) ⇒ Object
51
52
53
|
# File 'lib/redis_obj/sorted_set.rb', line 51
def zinterstore(destination, keys, options = {}, &blk)
store_block_syntax(:zinterstore,destination,keys,options,&blk)
end
|
#zremrangebyrank(start, stop = nil) ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/redis_obj/sorted_set.rb', line 33
def zremrangebyrank start, stop=nil
if start.respond_to?(:max) && start.respond_to?(:min)
stop = start.max
start = start.min
end
redis.zremrangebyrank(key,start,stop)
end
|
#zremrangebyscore(start, stop = nil) ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'lib/redis_obj/sorted_set.rb', line 42
def zremrangebyscore start, stop=nil
if start.respond_to?(:max) && start.respond_to?(:min)
stop = start.max
start = start.min
end
redis.zremrangebyscore(key,start,stop)
end
|
#zunionstore(destination, keys, options = {}, &blk) ⇒ Object
55
56
57
|
# File 'lib/redis_obj/sorted_set.rb', line 55
def zunionstore(destination, keys, options = {}, &blk)
store_block_syntax(:zunionstore,destination,keys,options,&blk)
end
|