Saturday, June 29, 2013

Redis client in C

I made a simple redis client in C based on the hiredis example (redis-2.6.14/deps/hiredis/example.c) to demonstrate how to use hiredis. You can compile it with cc -o redisclient redisclient.c libhiredis.a command or run makefile. If you want to specify the host from terminal, run ./redisclient If you don't define, it will use the adress and port in this example. Type exit to quit. Supported commands: get, set, del, incr, decr.

redis: get key
> value
redis: incr key
> ERR value is not an integer or out of range
redis: set key value 2
redis: get key
> value 2
redis: set age 21
redis: decr age
> 20
redis: incr age
> 21
redis: del age
> (null)

No comments:

Post a Comment