Class: Sym::App::Password::Providers::MemcachedProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/sym/app/password/providers/memcached_provider.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**opts) ⇒ MemcachedProvider

Returns a new instance of MemcachedProvider.



11
12
13
14
15
16
17
18
# File 'lib/sym/app/password/providers/memcached_provider.rb', line 11

def initialize(**opts)
  # disable logging
  Dalli.logger = Sym::Constants::Log::NIL
  self.dalli = ::Dalli::Client.new(
    * Sym::Configuration.config.password_cache_arguments[:memcached][:args],
    ** Sym::Configuration.config.password_cache_arguments[:memcached][:opts].merge!(opts)
  )
end

Instance Attribute Details

#dalliObject

Returns the value of attribute dalli.



9
10
11
# File 'lib/sym/app/password/providers/memcached_provider.rb', line 9

def dalli
  @dalli
end

Instance Method Details

#alive?Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
# File 'lib/sym/app/password/providers/memcached_provider.rb', line 20

def alive?
  dalli.alive!
  true
rescue Dalli::RingError => e
  false
end

#clearObject



35
36
37
# File 'lib/sym/app/password/providers/memcached_provider.rb', line 35

def clear
  dalli.flush
end

#read(key) ⇒ Object



27
28
29
# File 'lib/sym/app/password/providers/memcached_provider.rb', line 27

def read(key)
  dalli.get(key)
end

#write(key, value) ⇒ Object



31
32
33
# File 'lib/sym/app/password/providers/memcached_provider.rb', line 31

def write(key, value, *)
  dalli.set(key, value)
end