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_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

.create(backend: Constants::Backends::HASH) ⇒ ConvenientService::Support::Cache::Entities::Caches::Base

Parameters:

  • backend (Symbol) (defaults to: Constants::Backends::HASH)

Returns:



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/convenient_service/support/cache.rb', line 15

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