Class: Lite::Redis::Set
- Inherits:
-
Base
- Object
- Base
- Lite::Redis::Set
show all
- Defined in:
- lib/lite/redis/set.rb
Instance Attribute Summary
Attributes inherited from Base
#client
Instance Method Summary
collapse
-
#combine(*args) ⇒ Object
-
#count(key) ⇒ Object
-
#create(key, args) ⇒ Object
-
#create_combination(key, *args) ⇒ Object
-
#create_difference(key, *args) ⇒ Object
-
#create_intersection(key, *args) ⇒ Object
-
#destroy(key, args) ⇒ Object
-
#destroy_random(key) ⇒ Object
-
#difference(*args) ⇒ Object
-
#find(key) ⇒ Object
-
#intersection(key, *args) ⇒ Object
-
#move(key, destination, value) ⇒ Object
-
#sample(key, value = 1) ⇒ Object
-
#scan(key, cursor, opts = {}) ⇒ Object
-
#value?(key, value) ⇒ Boolean
Methods inherited from Base
#initialize, method_missing, #respond_to_method?, #respond_to_missing?
Instance Method Details
#combine(*args) ⇒ Object
11
12
13
|
# File 'lib/lite/redis/set.rb', line 11
def combine(*args)
client.sunion(*args)
end
|
#count(key) ⇒ Object
31
32
33
|
# File 'lib/lite/redis/set.rb', line 31
def count(key)
client.scard(key.to_s)
end
|
#create(key, args) ⇒ Object
35
36
37
|
# File 'lib/lite/redis/set.rb', line 35
def create(key, args)
client.sadd?(key.to_s, args)
end
|
#create_combination(key, *args) ⇒ Object
39
40
41
|
# File 'lib/lite/redis/set.rb', line 39
def create_combination(key, *args)
client.sunionstore(key.to_s, *args)
end
|
#create_difference(key, *args) ⇒ Object
43
44
45
|
# File 'lib/lite/redis/set.rb', line 43
def create_difference(key, *args)
client.sdiffstore(key.to_s, *args)
end
|
#create_intersection(key, *args) ⇒ Object
47
48
49
|
# File 'lib/lite/redis/set.rb', line 47
def create_intersection(key, *args)
client.sinterstore(key.to_s, *args)
end
|
#destroy(key, args) ⇒ Object
55
56
57
|
# File 'lib/lite/redis/set.rb', line 55
def destroy(key, args)
client.srem?(key.to_s, args)
end
|
#destroy_random(key) ⇒ Object
59
60
61
|
# File 'lib/lite/redis/set.rb', line 59
def destroy_random(key)
client.spop(key.to_s)
end
|
#difference(*args) ⇒ Object
15
16
17
|
# File 'lib/lite/redis/set.rb', line 15
def difference(*args)
client.sdiff(*args)
end
|
#find(key) ⇒ Object
7
8
9
|
# File 'lib/lite/redis/set.rb', line 7
def find(key)
client.smembers(key.to_s)
end
|
#intersection(key, *args) ⇒ Object
19
20
21
|
# File 'lib/lite/redis/set.rb', line 19
def intersection(key, *args)
client.sinter(key.to_s, *args)
end
|
#move(key, destination, value) ⇒ Object
51
52
53
|
# File 'lib/lite/redis/set.rb', line 51
def move(key, destination, value)
client.smove(key.to_s, destination.to_s, value)
end
|
#sample(key, value = 1) ⇒ Object
23
24
25
|
# File 'lib/lite/redis/set.rb', line 23
def sample(key, value = 1)
client.srandmember(key.to_s, value)
end
|
#scan(key, cursor, opts = {}) ⇒ Object
63
64
65
|
# File 'lib/lite/redis/set.rb', line 63
def scan(key, cursor, opts = {})
client.sscan(key.to_s, cursor, **opts)
end
|
#value?(key, value) ⇒ Boolean
27
28
29
|
# File 'lib/lite/redis/set.rb', line 27
def value?(key, value)
client.sismember(key.to_s, value)
end
|