Module: InfoparkComponentCache::KeyGenerator
- Defined in:
- lib/infopark_component_cache/key_generator.rb
Class Method Summary collapse
-
.encode_key(string) ⇒ String
Encodes a provided key yielding a string that only consists of alphanumeric characters of limited length.
-
.generate_key(anything) ⇒ String
Generates a key identifing an Object.
Class Method Details
.encode_key(string) ⇒ String
Encodes a provided key yielding a string that only consists of alphanumeric characters of limited length. Underlying implementation uses some kind of hashing algorithm and therefore has the same characteristics: equal inputs yield equal outputs, but different inputs can yield same outputs (although it is very very unlikely)
27 28 29 |
# File 'lib/infopark_component_cache/key_generator.rb', line 27 def self.encode_key(string) #:nodoc: Digest::SHA2.hexdigest(string) end |
.generate_key(anything) ⇒ String
Generates a key identifing an Object
13 14 15 |
# File 'lib/infopark_component_cache/key_generator.rb', line 13 def self.generate_key(anything) encode_key(Rails.cache.send(:expanded_key, anything)) end |