Sha256: eca389f5590af6f02beb677b0edc0a6f9684eac87ca4a9aa422467c9d385daa7

Contents?: true

Size: 868 Bytes

Versions: 1

Compression:

Stored size: 868 Bytes

Contents

require "socket"
require "bojack/version"

module BoJack
  class Client
    attr_accessor :hostname, :port

    def initialize(hostname = "127.0.0.1", port = 5000)
      @hostname = hostname
      @port = port
      @socket = TCPSocket.new(@hostname, @port)
      # @socket.tcp_nodelay = true
    end

    def set(key, value)
      send("set #{key} #{value}")
    end

    def increment(key)
      send("increment #{key}")
    end

    def get(key)
      send("get #{key}")
    end

    def append(key, value)
      send("append #{key} #{value}")
    end

    def pop(key)
      send("pop #{key}")
    end

    def delete(key)
      send("delete #{key}")
    end

    def ping
      send("ping")
    end

    def size
      send("size")
    end

    def close
      send("close")
    end

    def send(raw)
      @socket.puts(raw)
      @socket.gets
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bojack-0.1.0 lib/bojack.rb