Class: ActiveSupport::CachingKeyGenerator
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activesupport/lib/active_support/key_generator.rb |
Overview
Caching Key Generator
CachingKeyGenerator
is a wrapper around KeyGenerator
which allows users to avoid re-executing the key generation process when it’s called using the same salt
and key_size
.
Class Method Summary
- .new(key_generator) ⇒ CachingKeyGenerator constructor
Instance Method Summary
-
#generate_key(*args)
Returns a derived key suitable for use.
Constructor Details
.new(key_generator) ⇒ CachingKeyGenerator
# File 'activesupport/lib/active_support/key_generator.rb', line 56
def initialize(key_generator) @key_generator = key_generator @cache_keys = Concurrent::Map.new end
Instance Method Details
#generate_key(*args)
Returns a derived key suitable for use.
# File 'activesupport/lib/active_support/key_generator.rb', line 62
def generate_key(*args) @cache_keys[args.join("|")] ||= @key_generator.generate_key(*args) end