Class: ActiveSupport::CachingKeyGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/key_generator.rb

Overview

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.

Instance Method Summary collapse

Constructor Details

#initialize(key_generator) ⇒ CachingKeyGenerator

Returns a new instance of CachingKeyGenerator.



48
49
50
51
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/key_generator.rb', line 48

def initialize(key_generator)
  @key_generator = key_generator
  @cache_keys = Concurrent::Map.new
end

Instance Method Details

#generate_key(*args) ⇒ Object

Returns a derived key suitable for use.



54
55
56
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/key_generator.rb', line 54

def generate_key(*args)
  @cache_keys[args.join("|")] ||= @key_generator.generate_key(*args)
end