Sha256: 475ef0793e0452527a5dd3c780f3b6d3a40b79a9cd725c2d41e63860523fbbd9

Contents?: true

Size: 697 Bytes

Versions: 1

Compression:

Stored size: 697 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, val = "")
        @client.set(key, val)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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