Sha256: 395d73517686167c3b70b90c73e77e110a6e04c308ae9e8cf89562fdeb1a58fb

Contents?: true

Size: 688 Bytes

Versions: 4

Compression:

Stored size: 688 Bytes

Contents

require 'dalli'
require 'flipper'
require 'flipper/adapters/cache_base'

module Flipper
  module Adapters
    # Public: Adapter that wraps another adapter with the ability to cache
    # adapter calls in Memcached using the Dalli gem.
    class Dalli < CacheBase
      def initialize(adapter, cache, ttl = 0, prefix: nil)
        super
      end

      private

      def cache_fetch(key, &block)
        @cache.fetch(key, @ttl, &block)
      end

      def cache_read_multi(keys)
        @cache.get_multi(keys)
      end

      def cache_write(key, value)
        @cache.set(key, value, @ttl)
      end

      def cache_delete(key)
        @cache.delete(key)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
flipper-dalli-1.3.2 lib/flipper/adapters/dalli.rb
flipper-dalli-1.3.1 lib/flipper/adapters/dalli.rb
flipper-dalli-1.3.0 lib/flipper/adapters/dalli.rb
flipper-dalli-1.3.0.pre lib/flipper/adapters/dalli.rb