Class: ConvenientService::Support::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/convenient_service/support/cache.rb,
lib/convenient_service/support/cache/constants.rb,
lib/convenient_service/support/cache/exceptions.rb,
lib/convenient_service/support/cache/entities/key.rb,
lib/convenient_service/support/cache/entities/caches/base.rb,
lib/convenient_service/support/cache/entities/caches/hash.rb,
lib/convenient_service/support/cache/entities/caches/array.rb,
lib/convenient_service/support/cache/entities/caches/thread_safe_hash.rb,
lib/convenient_service/support/cache/entities/caches/thread_safe_array.rb,
lib/convenient_service/support/cache/entities/caches/array/entities/pair.rb

Defined Under Namespace

Modules: Constants, Entities, Exceptions

Class Method Summary collapse

Class Method Details

.backed_by(backend) ⇒ Class<ConvenientService::Support::Cache::Entities::Caches::Base>

Parameters:

  • backend (Symbol)

Returns:



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/convenient_service/support/cache.rb', line 27

def backed_by(backend)
  case backend
  when Constants::Backends::ARRAY
    Entities::Caches::Array
  when Constants::Backends::HASH
    Entities::Caches::Hash
  when Constants::Backends::THREAD_SAFE_ARRAY
    Entities::Caches::ThreadSafeArray
  when Constants::Backends::THREAD_SAFE_HASH
    Entities::Caches::ThreadSafeHash
  else
    ::ConvenientService.raise Exceptions::NotSupportedBackend.new(backend: backend)
  end
end

.newConvenientService::Support::Cache::Entities::Caches::Base



19
20
21
# File 'lib/convenient_service/support/cache.rb', line 19

def new(...)
  backed_by(Constants::Backends::DEFAULT).new(...)
end