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
-
#add(score, member) ⇒ Object
-
#card(min = 0, max = 0) ⇒ Object
(also: #length, #size, #count)
-
#dec(member) ⇒ Object
-
#inc(member) ⇒ Object
-
#incby(amt, member) ⇒ Object
-
#interstore(destination, keys, options = {}) ⇒ Object
-
#range(start, stop, opts = {}) ⇒ Object
-
#rangebyscore(start, stop, opts = {}) ⇒ Object
-
#rank(mem) ⇒ Object
-
#rem(member) ⇒ Object
-
#remrangebyrank(start, stop) ⇒ Object
-
#remrangebyscore(start, stop) ⇒ Object
-
#revrange(start, stop, opts = {}) ⇒ Object
-
#revrangebyscore(start, stop, opts = {}) ⇒ Object
-
#revrank(mem) ⇒ Object
-
#unionstore(destination, keys, options = {}) ⇒ Object
Methods inherited from Base
#==, #del_key, #initialize
Constructor Details
This class inherits a constructor from RedisObj::Base
Instance Method Details
#add(score, member) ⇒ Object
2
3
4
|
# File 'lib/redis_obj/sorted_set.rb', line 2
def add score, member
redis.zadd(key,score,member)
end
|
#card(min = 0, max = 0) ⇒ Object
Also known as:
length, size, count
10
11
12
13
14
15
16
|
# File 'lib/redis_obj/sorted_set.rb', line 10
def card min=0,max=0
if min
redis.zcount(key,min,max)
else
redis.zcard(key)
end
end
|
#dec(member) ⇒ Object
29
30
31
|
# File 'lib/redis_obj/sorted_set.rb', line 29
def dec member
incby(-1,member)
end
|
#inc(member) ⇒ Object
25
26
27
|
# File 'lib/redis_obj/sorted_set.rb', line 25
def inc member
incby(1,member)
end
|
#incby(amt, member) ⇒ Object
21
22
23
|
# File 'lib/redis_obj/sorted_set.rb', line 21
def incby amt, member
redis.zincby(key,amt,member)
end
|
#interstore(destination, keys, options = {}) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/redis_obj/sorted_set.rb', line 65
def interstore(destination, keys, options = {})
keys = [key]+keys
redis.zinterstore(destination,keys,options)
new_key = self.class.new(redis,destination)
if block_given?
begin
yield(new_key)
ensure
redis.del(destination)
end
end
new_key
end
|
#range(start, stop, opts = {}) ⇒ Object
33
34
35
|
# File 'lib/redis_obj/sorted_set.rb', line 33
def range start, stop, opts={}
redis.zrange(key,start,stop,opts)
end
|
#rangebyscore(start, stop, opts = {}) ⇒ Object
41
42
43
|
# File 'lib/redis_obj/sorted_set.rb', line 41
def rangebyscore start, stop, opts={}
redis.zrangebyscore(key,start,stop,opts)
end
|
#rank(mem) ⇒ Object
49
50
51
|
# File 'lib/redis_obj/sorted_set.rb', line 49
def rank mem
redis.rank(key,mem)
end
|
#rem(member) ⇒ Object
6
7
8
|
# File 'lib/redis_obj/sorted_set.rb', line 6
def rem member
redis.zrem(key,mem)
end
|
#remrangebyrank(start, stop) ⇒ Object
57
58
59
|
# File 'lib/redis_obj/sorted_set.rb', line 57
def remrangebyrank start, stop
redis.zremrangebyrank(key,start,stop)
end
|
#remrangebyscore(start, stop) ⇒ Object
61
62
63
|
# File 'lib/redis_obj/sorted_set.rb', line 61
def remrangebyscore start, stop
redis.zremrangebyscore(key,start,stop)
end
|
#revrange(start, stop, opts = {}) ⇒ Object
37
38
39
|
# File 'lib/redis_obj/sorted_set.rb', line 37
def revrange start, stop, opts={}
redis.zrevrange(key,start,stop,opts)
end
|
#revrangebyscore(start, stop, opts = {}) ⇒ Object
45
46
47
|
# File 'lib/redis_obj/sorted_set.rb', line 45
def revrangebyscore start, stop, opts={}
redis.zrevrangebyscore(key,start,stop,opts)
end
|
#revrank(mem) ⇒ Object
53
54
55
|
# File 'lib/redis_obj/sorted_set.rb', line 53
def revrank mem
redis.revrank(key,mem)
end
|
#unionstore(destination, keys, options = {}) ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/redis_obj/sorted_set.rb', line 83
def unionstore(destination, keys, options = {})
keys = [key]+keys
redis.zunionstore(destination,keys,options)
new_key = self.class.new(redis,destination)
if block_given?
begin
yield(new_key)
ensure
redis.del(destination)
end
end
new_key
end
|