Sha256: fd824d2b8f98b10f0c708e1a591ef6d5d6037367e43ea3968bfbc54acb08c680

Contents?: true

Size: 682 Bytes

Versions: 1

Compression:

Stored size: 682 Bytes

Contents

module Suo
  module Client
    class Redis < Base
      def initialize(key, options = {})
        options[:client] ||= ::Redis.new(options[:connection] || {})
        super
      end

      def clear
        @client.del(@key)
      end

      private

      def get
        [@client.get(@key), nil]
      end

      def set(newval, _)
        ret = @client.multi do |multi|
          multi.set(@key, newval)
        end

        ret && ret[0] == "OK"
      end

      def synchronize
        @client.watch(@key) do
          yield
        end
      ensure
        @client.unwatch
      end

      def initial_set(val = "")
        @client.set(@key, val)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
suo-0.3.0 lib/suo/client/redis.rb