Sha256: cc662200f770fec15f18b36ee7bb5a1fedb1bde0e3eafa1b29a4d17201be1511

Contents?: true

Size: 679 Bytes

Versions: 1

Compression:

Stored size: 679 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[0] == "OK"
      end

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

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