Class: Sym::App::Password::Providers::MemcachedProvider
- Defined in:
- lib/sym/app/password/providers/memcached_provider.rb
Instance Attribute Summary collapse
-
#dalli ⇒ Object
Returns the value of attribute dalli.
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #clear ⇒ Object
-
#initialize(**opts) ⇒ MemcachedProvider
constructor
A new instance of MemcachedProvider.
- #read(key) ⇒ Object
- #write(key, value) ⇒ Object
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
#dalli ⇒ Object
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
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 |
#clear ⇒ Object
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 |