Sha256: 5400a0e59320a12c22a34c926b6ff0f311333aea3430faa0dc520cadb00c68c8

Contents?: true

Size: 519 Bytes

Versions: 2

Compression:

Stored size: 519 Bytes

Contents

require "redic/client"

class Redic
  attr :url

  def initialize(url = "redis://127.0.0.1:6379")
    @url = url
    @client = Redic::Client.new(url)
    @buffer = []
  end

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

  def write(*args)
    @buffer << args
  end

  def run
    @client.connect do
      @buffer.each do |args|
        @client.write(args)
      end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redic-0.0.4 lib/redic.rb
redic-0.0.3 lib/redic.rb