Sha256: e031b8d02eb803afa69bac6882b2343ac7a6f96944a0f8b395351f000931c268

Contents?: true

Size: 1000 Bytes

Versions: 7

Compression:

Stored size: 1000 Bytes

Contents

require 'forwardable'
require 'dalli'
require 'sym/app/password/cache'

module Sym
  module App
    module Password
      module Providers
        class MemcachedProvider
          attr_accessor :dalli

          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

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

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

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

          def clear
            dalli.flush
          end

        end

        register MemcachedProvider
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sym-2.6.2 lib/sym/app/password/providers/memcached_provider.rb
sym-2.6.1 lib/sym/app/password/providers/memcached_provider.rb
sym-2.6.0 lib/sym/app/password/providers/memcached_provider.rb
sym-2.5.3 lib/sym/app/password/providers/memcached_provider.rb
sym-2.5.1 lib/sym/app/password/providers/memcached_provider.rb
sym-2.5.0 lib/sym/app/password/providers/memcached_provider.rb
sym-2.4.3 lib/sym/app/password/providers/memcached_provider.rb