# File lib/redis_queryable.rb, line 18
18: def self.get namespace, key_hash
19: key = build_key key_hash.values
20: redis = switch_to_namespace namespace
21: json = redis.get key
22: Hashie::Mash.new(JSON.parse(json))
23: end
# File lib/redis_queryable.rb, line 25
25: def self.look_up_key namespace, key_hash, &block
26: if exists_key? namespace, key_hash
27: get namespace, key_hash
28: else
29: block.call
30: end
31: end
# File lib/redis_queryable.rb, line 10
10: def self.store namespace, key_hash, value
11: key = build_key key_hash.values
12: redis = switch_to_namespace namespace
13:
14: expires = key_hash.has_key?(:type) ? EXPIRATION[namespace][key_hash[:type]] : EXPIRATION[namespace]
15: redis.setex key, expires.to_i.days, value
16: end
# File lib/redis_queryable.rb, line 42
42: def self.build_key key_array
43: key_array.flatten.map do |value|
44: value.is_a?(String) ? Digest::SHA1.hexdigest(value) : value.to_s
45: end.join(":")
46: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.