Sha256: f916f0bdc31faca6e852428ef548ec53ebe00683081421af4023fbe4a200950f

Contents?: true

Size: 613 Bytes

Versions: 2

Compression:

Stored size: 613 Bytes

Contents

require_relative "redic/client"

class Redic
  attr :url
  attr :client

  def initialize(url = "redis://127.0.0.1:6379", timeout = 10_000_000)
    @url = url
    @client = Redic::Client.new(url, timeout)
    @queue = []
  end

  def call(*args)
    @client.connect do
      @client.write(args)
      @client.read
    end
  end

  def queue(*args)
    @queue << args
  end

  def commit
    @client.connect do
      @queue.each do |args|
        @client.write(args)
      end

      @queue.map do
        @client.read
      end
    end
  ensure
    @queue.clear
  end

  def timeout
    @client.timeout
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redic-1.1.1 lib/redic.rb
redic-1.1.0 lib/redic.rb