Class: Lite::Redis::SortedSet
- Inherits:
-
Base
- Object
- Base
- Lite::Redis::SortedSet
show all
- Defined in:
- lib/lite/redis/sorted_set.rb
Instance Attribute Summary
Attributes inherited from Base
#client
Instance Method Summary
collapse
-
#all(key, opts = {}) ⇒ Object
-
#all_reverse(key, opts = {}) ⇒ Object
-
#between(key, start, finish, opts = {}) ⇒ Object
-
#between_lex(key, min, max, opts = {}) ⇒ Object
-
#between_lex_reverse(key, min, max, opts = {}) ⇒ Object
-
#between_reverse(key, start, finish, opts = {}) ⇒ Object
-
#between_scores(key, min, max, opts = {}) ⇒ Object
-
#between_scores_reverse(key, min, max, opts = {}) ⇒ Object
-
#count(key) ⇒ Object
-
#count_between(key, min, max) ⇒ Object
-
#create(key, *args) ⇒ Object
-
#create_combination(key, keys, opts = {}) ⇒ Object
-
#create_intersection(key, keys, opts = {}) ⇒ Object
-
#decrement(key, value, count) ⇒ Object
-
#destroy(key, at) ⇒ Object
-
#destroy_between(key, start, finish) ⇒ Object
-
#destroy_lex(key, min, max, opts = {}) ⇒ Object
-
#destroy_scores(key, min, max) ⇒ Object
-
#find(key, position, opts = {}) ⇒ Object
-
#find_score(key, position, opts = {}) ⇒ Object
-
#first(key, opts = {}) ⇒ Object
-
#first_score(key, opts = {}) ⇒ Object
-
#increment(key, value, count) ⇒ Object
-
#last(key, opts = {}) ⇒ Object
-
#last_score(key, opts = {}) ⇒ Object
-
#position(key, value) ⇒ Object
-
#position_reverse(key, value) ⇒ Object
-
#scan(key, cursor, opts = {}) ⇒ Object
-
#score(key, value) ⇒ Object
Methods inherited from Base
#initialize, method_missing, #respond_to_method?, #respond_to_missing?
Instance Method Details
#all(key, opts = {}) ⇒ Object
62
63
64
|
# File 'lib/lite/redis/sorted_set.rb', line 62
def all(key, opts = {})
client.zrange(key.to_s, 0, -1, **opts)
end
|
#all_reverse(key, opts = {}) ⇒ Object
66
67
68
|
# File 'lib/lite/redis/sorted_set.rb', line 66
def all_reverse(key, opts = {})
client.zrevrange(key.to_s, 0, -1, **opts)
end
|
#between(key, start, finish, opts = {}) ⇒ Object
38
39
40
|
# File 'lib/lite/redis/sorted_set.rb', line 38
def between(key, start, finish, opts = {})
client.zrange(key.to_s, start - 1, finish - 1, **opts)
end
|
#between_lex(key, min, max, opts = {}) ⇒ Object
54
55
56
|
# File 'lib/lite/redis/sorted_set.rb', line 54
def between_lex(key, min, max, opts = {})
client.zrangebylex(key.to_s, min, max, **opts)
end
|
#between_lex_reverse(key, min, max, opts = {}) ⇒ Object
58
59
60
|
# File 'lib/lite/redis/sorted_set.rb', line 58
def between_lex_reverse(key, min, max, opts = {})
client.zrevrangebylex(key.to_s, min, max, **opts)
end
|
#between_reverse(key, start, finish, opts = {}) ⇒ Object
42
43
44
|
# File 'lib/lite/redis/sorted_set.rb', line 42
def between_reverse(key, start, finish, opts = {})
client.zrevrange(key.to_s, start - 1, finish - 1, **opts)
end
|
#between_scores(key, min, max, opts = {}) ⇒ Object
46
47
48
|
# File 'lib/lite/redis/sorted_set.rb', line 46
def between_scores(key, min, max, opts = {})
client.zrangebyscore(key.to_s, min, max, **opts)
end
|
#between_scores_reverse(key, min, max, opts = {}) ⇒ Object
50
51
52
|
# File 'lib/lite/redis/sorted_set.rb', line 50
def between_scores_reverse(key, min, max, opts = {})
client.zrevrangebyscore(key.to_s, min, max, **opts)
end
|
#count(key) ⇒ Object
86
87
88
|
# File 'lib/lite/redis/sorted_set.rb', line 86
def count(key)
client.zcard(key.to_s)
end
|
#count_between(key, min, max) ⇒ Object
90
91
92
|
# File 'lib/lite/redis/sorted_set.rb', line 90
def count_between(key, min, max)
client.zcount(key.to_s, min, max)
end
|
#create(key, *args) ⇒ Object
94
95
96
|
# File 'lib/lite/redis/sorted_set.rb', line 94
def create(key, *args)
client.zadd(key.to_s, args)
end
|
#create_combination(key, keys, opts = {}) ⇒ Object
102
103
104
|
# File 'lib/lite/redis/sorted_set.rb', line 102
def create_combination(key, keys, opts = {})
client.zunionstore(key.to_s, keys, **opts)
end
|
#create_intersection(key, keys, opts = {}) ⇒ Object
98
99
100
|
# File 'lib/lite/redis/sorted_set.rb', line 98
def create_intersection(key, keys, opts = {})
client.zinterstore(key.to_s, keys, **opts)
end
|
#decrement(key, value, count) ⇒ Object
110
111
112
|
# File 'lib/lite/redis/sorted_set.rb', line 110
def decrement(key, value, count)
client.zincrby(key.to_s, -count.abs, value)
end
|
#destroy(key, at) ⇒ Object
114
115
116
|
# File 'lib/lite/redis/sorted_set.rb', line 114
def destroy(key, at)
client.zrem(key.to_s, at)
end
|
#destroy_between(key, start, finish) ⇒ Object
118
119
120
|
# File 'lib/lite/redis/sorted_set.rb', line 118
def destroy_between(key, start, finish)
client.zremrangebyrank(key.to_s, start - 1, finish - 1)
end
|
#destroy_lex(key, min, max, opts = {}) ⇒ Object
126
127
128
|
# File 'lib/lite/redis/sorted_set.rb', line 126
def destroy_lex(key, min, max, opts = {})
client.zrevrangebylex(key.to_s, max, min, **opts)
end
|
#destroy_scores(key, min, max) ⇒ Object
122
123
124
|
# File 'lib/lite/redis/sorted_set.rb', line 122
def destroy_scores(key, min, max)
client.zremrangebyscore(key.to_s, min, max)
end
|
#find(key, position, opts = {}) ⇒ Object
7
8
9
10
11
|
# File 'lib/lite/redis/sorted_set.rb', line 7
def find(key, position, opts = {})
position -= 1
value = client.zrange(key.to_s, position, position, **opts)
value.first
end
|
#find_score(key, position, opts = {}) ⇒ Object
13
14
15
16
|
# File 'lib/lite/redis/sorted_set.rb', line 13
def find_score(key, position, opts = {})
value = client.zrangebyscore(key.to_s, position, position, **opts)
value.first
end
|
#first(key, opts = {}) ⇒ Object
18
19
20
21
|
# File 'lib/lite/redis/sorted_set.rb', line 18
def first(key, opts = {})
value = client.zrange(key.to_s, 0, 0, **opts)
value.first
end
|
#first_score(key, opts = {}) ⇒ Object
23
24
25
26
|
# File 'lib/lite/redis/sorted_set.rb', line 23
def first_score(key, opts = {})
value = client.zrangebyscore(key.to_s, 1, 1, **opts)
value.first
end
|
#increment(key, value, count) ⇒ Object
106
107
108
|
# File 'lib/lite/redis/sorted_set.rb', line 106
def increment(key, value, count)
client.zincrby(key.to_s, count, value)
end
|
#last(key, opts = {}) ⇒ Object
28
29
30
31
|
# File 'lib/lite/redis/sorted_set.rb', line 28
def last(key, opts = {})
value = client.zrevrange(key.to_s, 0, 0, **opts)
value.first
end
|
#last_score(key, opts = {}) ⇒ Object
33
34
35
36
|
# File 'lib/lite/redis/sorted_set.rb', line 33
def last_score(key, opts = {})
value = client.zrevrangebyscore(key.to_s, 1, 1, **opts)
value.first
end
|
#position(key, value) ⇒ Object
70
71
72
73
74
|
# File 'lib/lite/redis/sorted_set.rb', line 70
def position(key, value)
value = client.zrank(key.to_s, value)
value += 1 unless value.nil?
value
end
|
#position_reverse(key, value) ⇒ Object
76
77
78
79
80
|
# File 'lib/lite/redis/sorted_set.rb', line 76
def position_reverse(key, value)
value = client.zrevrank(key.to_s, value)
value += 1 unless value.nil?
value
end
|
#scan(key, cursor, opts = {}) ⇒ Object
130
131
132
|
# File 'lib/lite/redis/sorted_set.rb', line 130
def scan(key, cursor, opts = {})
client.zscan(key.to_s, cursor, **opts)
end
|
#score(key, value) ⇒ Object
82
83
84
|
# File 'lib/lite/redis/sorted_set.rb', line 82
def score(key, value)
client.zscore(key.to_s, value)
end
|