Class: Swarm::Storage::RedisStorage
Instance Attribute Summary
#store
Instance Method Summary
collapse
#[], #[]=, #add_association, #deserialize, #initialize, #load_associations, #regex_for_type, #serialize, #trace, #trace=
Instance Method Details
#all_of_type(type, subtypes: true) ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/swarm/storage/redis_storage.rb', line 13
def all_of_type(type, subtypes: true)
hsh = store.mapped_mget(*store.keys("#{type}:*"))
if subtypes
hsh.values
else
hsh.select { |_key, value| value["type"] == type }.values
end
end
|
#delete(key) ⇒ Object
22
23
24
|
# File 'lib/swarm/storage/redis_storage.rb', line 22
def delete(key)
store.del(key)
end
|
#ids_for_type(type) ⇒ Object
9
10
11
|
# File 'lib/swarm/storage/redis_storage.rb', line 9
def ids_for_type(type)
store.keys("#{type}:*").map { |key| key.gsub(regex_for_type(type), '\1') }
end
|
#truncate ⇒ Object
26
27
28
|
# File 'lib/swarm/storage/redis_storage.rb', line 26
def truncate
store.flushdb
end
|