Class: Swarm::Storage::RedisStorage
Instance Attribute Summary
#store
Instance Method Summary
collapse
#[], #[]=, #deserialize, #initialize, #load_associations, #regex_for_type, #serialize, #trace, #trace=
Instance Method Details
#all_of_type(type, subtypes: true) ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'lib/swarm/storage/redis_storage.rb', line 11
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
20
21
22
|
# File 'lib/swarm/storage/redis_storage.rb', line 20
def delete(key)
store.del(key)
end
|
#ids_for_type(type) ⇒ Object
7
8
9
|
# File 'lib/swarm/storage/redis_storage.rb', line 7
def ids_for_type(type)
store.keys("#{type}:*").map { |key| key.gsub(regex_for_type(type), '\1') }
end
|
#truncate ⇒ Object
24
25
26
|
# File 'lib/swarm/storage/redis_storage.rb', line 24
def truncate
store.flushdb
end
|