Class: ActiveOrm::Redis::Set
Instance Attribute Summary
#client
Attributes inherited from Base
#configuration
Class 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
client, #initialize
Methods included from Base
#evaluate, #evaluate?
Methods inherited from Base
configuration, configuration=, configure
Class Method Details
.combine(*args) ⇒ Object
9
10
11
12
13
|
# File 'lib/active_orm/redis/set.rb', line 9
def self.combine(*args)
value = client.sunion(*args)
value = metatransform(value)
return(value)
end
|
.count(key) ⇒ Object
37
38
39
|
# File 'lib/active_orm/redis/set.rb', line 37
def self.count(key)
client.scard(normalize_key(key))
end
|
.create(key, *args) ⇒ Object
41
42
43
|
# File 'lib/active_orm/redis/set.rb', line 41
def self.create(key, *args)
client.sadd(normalize_key(key), args)
end
|
.create_combination(key, *args) ⇒ Object
45
46
47
|
# File 'lib/active_orm/redis/set.rb', line 45
def self.create_combination(key, *args)
client.sunionstore(normalize_key(key), *args)
end
|
.create_difference(key, *args) ⇒ Object
49
50
51
|
# File 'lib/active_orm/redis/set.rb', line 49
def self.create_difference(key, *args)
client.sdiffstore(normalize_key(key), *args)
end
|
.create_intersection(key, *args) ⇒ Object
53
54
55
|
# File 'lib/active_orm/redis/set.rb', line 53
def self.create_intersection(key, *args)
client.sinterstore(normalize_key(key), *args)
end
|
.destroy(key, *args) ⇒ Object
61
62
63
|
# File 'lib/active_orm/redis/set.rb', line 61
def self.destroy(key, *args)
client.srem(normalize_key(key), *args)
end
|
.destroy_random(key) ⇒ Object
65
66
67
|
# File 'lib/active_orm/redis/set.rb', line 65
def self.destroy_random(key)
client.spop(normalize_key(key))
end
|
.difference(*args) ⇒ Object
15
16
17
18
19
|
# File 'lib/active_orm/redis/set.rb', line 15
def self.difference(*args)
value = client.sdiff(*args)
value = metatransform(value)
return(value)
end
|
.find(key) ⇒ Object
3
4
5
6
7
|
# File 'lib/active_orm/redis/set.rb', line 3
def self.find(key)
value = client.smembers(normalize_key(key))
value = metatransform(value)
return(value)
end
|
.intersection(key, *args) ⇒ Object
21
22
23
24
25
|
# File 'lib/active_orm/redis/set.rb', line 21
def self.intersection(key, *args)
value = client.sinter(normalize_key(key), *args)
value = metatransform(value)
return(value)
end
|
.move(key, destination, value) ⇒ Object
57
58
59
|
# File 'lib/active_orm/redis/set.rb', line 57
def self.move(key, destination, value)
client.smove(normalize_key(key), destination.to_s, value)
end
|
.sample(key, value = 1) ⇒ Object
27
28
29
30
31
|
# File 'lib/active_orm/redis/set.rb', line 27
def self.sample(key, value=1)
value = client.srandmember(normalize_key(key), value)
value = metatransform(value)
return(value)
end
|
.scan(key, cursor, opts = {}) ⇒ Object
69
70
71
|
# File 'lib/active_orm/redis/set.rb', line 69
def self.scan(key, cursor, opts={})
client.sscan(normalize_key(key), cursor, opts)
end
|
.value?(key, value) ⇒ Boolean
33
34
35
|
# File 'lib/active_orm/redis/set.rb', line 33
def self.value?(key, value)
client.sismember(normalize_key(key), value)
end
|