Sha256: 8cd102d786114b673ef7d279f067a6790e3a5bbdc4d26846b7f7a015bd28b721

Contents?: true

Size: 686 Bytes

Versions: 1

Compression:

Stored size: 686 Bytes

Contents

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

      def clear(key)
        @client.del(key)
      end

      private

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

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

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

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