21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/config_manager/settings/querying.rb', line 21
def all
keys = $redis.smembers(global_key)
return [] if keys.empty?
values = $redis.mget(*keys)
obsolete_keys = Range.new(0, keys.size, true).inject([]) do |memo, i|
values.at(i) ? memo : (memo << keys.at(i))
end
unless obsolete_keys.empty?
Rails.logger.info("DELETING OBSOLETE KEYS IN GLOBAL INDEX: #{obsolete_keys}")
$redis.srem(global_key, obsolete_keys)
keys = keys - obsolete_keys
values.compact!
end
ids = keys.map {|k| k.gsub("#{prefix}:", '') }
tag_keys = ids.map {|id| generate_tags_key(id) }
tags = tag_keys.map {|key| $redis.smembers(key) }
ids.zip(values, tags).map do |i,v, t|
Setting.new(i, v, t)
end
end
|