Sha256: 823554ecfaaf204f0c7cc819be2ad61c494baf5067e9d09504a3754c6847abeb

Contents?: true

Size: 716 Bytes

Versions: 1

Compression:

Stored size: 716 Bytes

Contents

module Suo
  module Client
    class Memcached < Base
      def initialize(key, options = {})
        options[:client] ||= Dalli::Client.new(options[:connection] || ENV["MEMCACHE_SERVERS"] || "127.0.0.1:11211")
        super
      end

      def clear
        @client.delete(@key)
      end

      private

      def get
        @client.get_cas(@key)
      end

      def set(newval, cas, expire: false)
        if expire
          @client.set_cas(@key, newval, cas, @options[:ttl])
        else
          @client.set_cas(@key, newval, cas)
        end
      end

      def initial_set(val = BLANK_STR)
        @client.set(@key, val)
        _val, cas = @client.get_cas(@key)
        cas
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
suo-0.3.3 lib/suo/client/memcached.rb