Sha256: e05265fc37966b259d8a10ecd33b172435e8ed6c7c43a63d4d24aae02de15a48

Contents?: true

Size: 756 Bytes

Versions: 5

Compression:

Stored size: 756 Bytes

Contents

module CrossStub
  module Stores
    class Memcache < Base

      def initialize(connection_and_cache_id, truncate = true)
        require 'memcache'
        connection, @cache_id = connection_and_cache_id.split('/')
        @memcache = MemCache.new(connection)
        super(truncate)
      end

      def current
        @cache_id
      end

      def previous
        "#{@cache_id}.stale"
      end

      private

        def exists?(cache_id)
          not @memcache[cache_id].nil?
        end

        def dump(cache_id, data)
          @memcache[cache_id] = data
        end

        def load(cache_id)
          @memcache[cache_id] || {}
        end

        def delete(cache_id)
          @memcache.delete(cache_id)
        end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cross-stub-0.2.4 lib/cross-stub/stores/memcache.rb
cross-stub-0.2.3 lib/cross-stub/stores/memcache.rb
cross-stub-0.2.2 lib/cross-stub/stores/memcache.rb
cross-stub-0.2.1 lib/cross-stub/stores/memcache.rb
cross-stub-0.2.0 lib/cross-stub/stores/memcache.rb