-Inferno Redis Client: A Very Alpha Software Release
-__ __ _
-\ \ / /__ _ __| | _____ ___ _ __ _ __ ___ _ _
- \ \ /\ / / _ \| '__| |/ / __| / _ \| '_ \ | '_ ` _ \| | | |
- \ V V / (_) | | | <\__ \ | (_) | | | | | | | | | | |_| |
- \_/\_/ \___/|_| |_|\_\___/ \___/|_| |_| |_| |_| |_|\__, |
- |___/
- _ _ _
- _ __ ___ __ _ ___| |__ (_)_ __ ___| |
-| '_ ` _ \ / _` |/ __| '_ \| | '_ \ / _ \ |
-| | | | | | (_| | (__| | | | | | | | __/_|
-|_| |_| |_|\__,_|\___|_| |_|_|_| |_|\___(_)
+- Inferno Redis Client: An Apparently Working Software Release
+This code contains a library and an interactive client for talking to Redis
+(https://redis.io/) from the Inferno OS
+(http://www.vitanuova.com/inferno/index.html). I am currently using the
+interactive client regularly.
-This code contains a library and an interactive client. I am currently using
-the interactive client daily. I like Redis. If you start seeing fewer updates,
-that means I have found fewer bugs (either directly or by reports).
+I use Redis for fun and profit, as well as Inferno. I wanted to talk to Redis
+from Inferno without using os(10).
-I wanted to talk to Redis from Inferno without using os(10).
+- Installing
-Installing: mk install. Set $ROOT if you are doing it from outside Inferno.
+ % mk install
-API Stability: No. The current API is bad and wrong.
+Set $ROOT if you are running mk from the host OS, you will need to add
+'ROOT=/path/to/inferno' to the mk command.
-Documentation: See the man pages.
+- Documentation
-Plans: Less buggy, better API, better man pages. Filesystem interface.
+The command and the library have man pages (which note some bugs).
+
+- Future development
+
+It'd be nice to fix some of the bugs by special-casing the commands.
+
+The man pages could stand some help.
+
+A filesystem interface would be nice.
redis := load Redis Redis->PATH;
initmod: fn(s: Sys, d: Dial, b: Bufio, st: String);
-call: fn(io: ref Iobuf, cmd: list of string):
- list of (int, string);
-sendcmd: fn(io: ref Iobuf, cmd: list of string): int;
-parseresult: fn(io: ref Iobuf): list of (int, string);
+connect: fn(addr: string): ref RedisClient;
+client: fn(io: ref Iobuf): ref RedisClient;
+
+parsecmd: fn(s: string, qc: int): (list of string, int);
+packcmd: fn(cmd: list of string): string;
+
RStr, RInt, RErr: con iota + 1;
+setdebug: fn(state: int);
+
+RedisClient: adt {
+ call: fn(c: self ref RedisClient, cmd: list of string): list of (int, string);
+
+ # You probably won't need these:
+ sendcmd: fn(c: self ref RedisClient, cmd: list of string): int;
+ printresult: fn(c: self ref RedisClient);
+ parseresult: fn(c: self ref RedisClient): list of (int, string);
+
+ # Internal:
+ io: ref Bufio->Iobuf;
+};
+
.EE
You will probably only need the
.I call()
function after calling
-.I initmod().
-.I call()
-and the rest of the code will probably change. It takes lists of strings and
-returns lists of tuples, each containing a type tag and a string
-representation of the data.
+.I initmod()
+to initialize the module and
+.I connect()
+to dial a server. If you have your own
+.I ref Iobuf
+and you you would prefer to manage the connection yourself, you can use
+.I client()
+to initialize a client with that Iobuf.
+
+.I RedisClient.call()
+takes lists of strings representing a command and its arguments, and returns
+lists of tuples, each containing a type tag (one of
+.I RStr
+,
+.I RInt
+,
+or
+.I Rerr
+) and a string representation of the data.
.I sendcmd()
and
# The library wants some modules passed in:
redis->initmod(sys, dial, bufio, str);
-# Do a connection and wrap the data FD in an Iobuf.
-# See the source for redis(1) for an example.
+# The client:
+client: ref RedisClient = redis->connect('tcp!localhost!6379');
-redis->call(c, "SET" :: "X" :: "5" :: nil);
-redis->call(c, "INCRBY" :: "X" :: "3" :: nil);
+client->call(c, "SET" :: "X" :: "5" :: nil);
+client->call(c, "INCRBY" :: "X" :: "3" :: nil);
# Returns (RInt, "8") :: nil
-redis->call(c, "HSET" :: "HT" :: "X" :: "five" :: nil);
-redis->call(c, "HGETALL" :: "HT" :: nil);
+client->call(c, "HSET" :: "HT" :: "X" :: "five" :: nil);
+client->call(c, "HGETALL" :: "HT" :: nil);
# Returns (RStr, "X") :: (RStr, "five") :: nil
-redis->call(c, "KEYS" :: "*" :: nil);
+client->call(c, "KEYS" :: "*" :: nil);
# Returns (Rstr, "X") :: (Rstr, "HT") :: nil
.EE
.IR bufio (2)
.SH BUGS
-This is alpha software. It works on my machine and currently does the
-right thing, usually.
+It works on my machine and currently does the right thing so far. This being a new release, no one else has used it so the usual caveats apply.
Errors are ignored unless generated by the server. So a missing argument will display the error that the server sends back, but a failure on our part to parse a response from the server is silently ignored.
-The interface will change. In particular, it is likely that there will be a
-client struct that will carry errors around so that you can see the errors.
-There are some other functions the module exports but none of those will
-remain in their current form.
-
-Most of the interface is undocumented, because it will change.
+The interface will probably change. In particular, it is likely that
+.I RedisClient
+ will carry errors around so that you can see the errors.