summaryrefslogtreecommitdiff
path: root/example.c
diff options
context:
space:
mode:
Diffstat (limited to 'example.c')
-rw-r--r--example.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/example.c b/example.c
index 5ec85e3..2de310f 100644
--- a/example.c
+++ b/example.c
@@ -6,6 +6,7 @@
int main(void) {
int fd;
+ unsigned int j;
redisReply *reply;
reply = redisConnect(&fd, "127.0.0.1", 6379);
@@ -29,5 +30,23 @@ int main(void) {
printf("SET (binary API): %s\n", reply->reply);
freeReplyObject(reply);
+ /* Create a list of numbers, from 0 to 9 */
+ for (j = 0; j < 10; j++) {
+ char buf[64];
+
+ snprintf(buf,64,"%d",j);
+ reply = redisCommand(fd,"LPUSH mylist element-%s", buf);
+ freeReplyObject(reply);
+ }
+
+ /* Let's check what we have inside the list */
+ reply = redisCommand(fd,"LRANGE mylist 0 -1");
+ if (reply->type == REDIS_REPLY_ARRAY) {
+ for (j = 0; j < reply->elements; j++) {
+ printf("%u) %s\n", j, reply->element[j]->reply);
+ }
+ }
+ freeReplyObject(reply);
+
return 0;
}