Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
A basic Redis client in Io.
//metadoc Redis Alice Kaerast 2011
/*metadoc Redis description
redis is an open source, advanced key-value store
<br />An example:
myredis := Redis clone connect("")
myredis send("rpush", "foo", "bar")
Redis := Object clone do(
debug ::= true
connect := method(addr,
if(debug, writeln("connecting"))
host := addr split(":") first
port := addr split(":") second asNumber
self socket := Socket clone setHost(host) setPort(port) connect
if(debug, writeln("connected"))
disconnect := method(
socket close
send := method(
methodSize := call message arguments size
i := 0
sendString := ""
while(i < methodSize, sendString := sendString .. call evalArgAt(i) .. " "; i = i + 1)
command := method(cmd,
cmd := cmd split
cmdstring := "*#{cmd size}\r\n" interpolate
i := 0
while(i < cmd size, cmdstring := cmdstring .. "$#{cmd at(i) size}\r\n#{cmd at(i)}\r\n" interpolate; i := i + 1)
cmdstring := cmdstring
socket streamWrite(cmdstring)
response := socket readUntilSeq("\r\n") split
myredis := Redis clone connect("")
myredis send("rpush", "foo", "bar") println
myredis send("exists", "foo") println
myredis send("exists", "bar") println
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.