Module: Redis::KeyHelper
- Included in:
- BigHash, NativeHash
- Defined in:
- lib/redis/key_helper.rb
Instance Method Summary collapse
- #convert_key(key) ⇒ Object
- #generate_key ⇒ Object
- #key ⇒ Object
- #redis_key(key = nil, namespace = nil) ⇒ Object
Instance Method Details
#convert_key(key) ⇒ Object
19 20 21 |
# File 'lib/redis/key_helper.rb', line 19 def convert_key(key) key.to_s end |
#generate_key ⇒ Object
8 9 10 11 |
# File 'lib/redis/key_helper.rb', line 8 def generate_key t = Time.now t.strftime('%Y%m%d%H%M%S.') + t.usec.to_s.rjust(6,'0') + '.' + SecureRandom.hex(16) end |
#key ⇒ Object
4 5 6 |
# File 'lib/redis/key_helper.rb', line 4 def key @key ||= generate_key end |
#redis_key(key = nil, namespace = nil) ⇒ Object
13 14 15 16 17 |
# File 'lib/redis/key_helper.rb', line 13 def redis_key(key = nil, namespace = nil) key ||= self.key namespace ||= self.namespace namespace.nil? ? key : "#{namespace}:#{key}" end |