Sha256: f27f8ce79765845468066f0c924da9d64b31cf66b3ff2665fd889b3ba1587a19

Contents?: true

Size: 747 Bytes

Versions: 3

Compression:

Stored size: 747 Bytes

Contents

module AmaLayout
  module Notifications
    class RedisStore < AbstractStore
      delegate :clear, to: :base

      attr_accessor :base

      def initialize(opts = {})
        self.base = ActiveSupport::Cache.lookup_store(
          :redis_store,
          opts.merge(raw: true)
        )
      end

      def get(key, opts = {})
        if opts.fetch(:default, false)
          base.fetch(key) { opts[:default] }
        else
          base.read(key)
        end
      end

      def set(key, value, opts = {})
        base.write(key, value, opts)
      end

      def delete(key, opts = {})
        base.delete(key, opts)
      end

      def transaction
        base.data.multi do
          yield self
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ama_layout-11.5.1 lib/ama_layout/notifications/redis_store.rb
ama_layout-11.5.0 lib/ama_layout/notifications/redis_store.rb
ama_layout-11.4.0 lib/ama_layout/notifications/redis_store.rb