Sha256: fea484a6a86b832b142606c7a88ca2f1667e2a53b3f4936e9f051425641346c8

Contents?: true

Size: 907 Bytes

Versions: 2

Compression:

Stored size: 907 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
            # disable logging
            Dalli.logger = Sym::LOGGER
            self.dalli = ::Dalli::Client.new(
              * Sym::Configuration.config.password_cache_arguments[:memcached][:args],
              ** Sym::Configuration.config.password_cache_arguments[:memcached][: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

        end

        register MemcachedProvider
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sym-2.2.1 lib/sym/app/password/providers/memcached_provider.rb
sym-2.2.0 lib/sym/app/password/providers/memcached_provider.rb