Sha256: 943cf8ff202942f2020354c35476beebf8e105a85b61cb95244fa90bdc1212be

Contents?: true

Size: 984 Bytes

Versions: 1

Compression:

Stored size: 984 Bytes

Contents

require 'remix/stash'

module ActiveSupport
  module Cache
    class RemixStashStore < Store
      include Remix
      
      def initialize(*servers)
        name = :active_support_cache
        if servers.last.is_a?(Hash)
          # were passing extra settings
          opts = servers.pop
          name = opts.delete(:name) if opts[:name]
          stash.default(opts)
        end
        Remix::Stash.define_cluster(:environment => servers)
        stash(name).default(:cluster => :environment)      
        @stash = stash(name)
      end

      def read(name, options = nil)
        super
        @stash[name]
      end

      def write(name, value, options = nil)
        super
        @stash[name] = value.freeze
      end

      def delete(name, options = nil)
        super
        @stash.clear(name)
      end

      def exist?(name, options = nil)
        super
        @stash.read(name)
      end

      def clear
        @stash.clear
      end
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
remix-stash-1.1.3 lib/active_support/cache/remix_stash_store.rb