I have written a small code for this particular requirement using hiredis , please find the code with a working example at http://rachitjain1.blogspot.in/2013/10/how-to-get-all-keyvalue-in-redis-db.html
Here is the code that I have written,
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hiredis.h"
int main(void)
{
unsigned int i,j=0;char **str1;
redisContext *c; char *t;
redisReply *reply, *rep;
struct timeval timeout = { 1, 500000 }; // 1.5 seconds
c = redisConnectWithTimeout((char*)"127.0.0.2", 6903, timeout);
if (c->err) {
printf("Connection error: %s\n", c->errstr);
exit(1);
}
reply = redisCommand(c,"keys *");
printf("KEY\t\tVALUE\n");
printf("------------------------\n");
while ( reply->element[j]->str != NULL)
{
rep = redisCommand(c,"GET %s", reply->element[j]->str);
if (strstr(rep->str,"ERR Operation against a key holding"))
{
printf("%s\t\t%s\n", reply->element[j]->str,rep->str);
break;
}
printf("%s\t\t%s\n", reply->element[j]->str,rep->str);
j++;
freeReplyObject(rep);
}
}