Redis (REmote DIctionary Server) is an advanced key-value store written in C. It can be used like memcached, in front of a traditional database, or on its own thanks to the fact that the in-memory datasets is not volatile, and values can be strings, but also lists, sets, and ordered sets and can be persisted on disk.
In order to be very fast but at the same time persistent the whole dataset is taken in memory, and from time to time saved on disc asynchronously (semi persistent mode) or alternatively every change is written into an append only file (fully persistent mode). Redis is able to rebuild the append only file in background when it gets too big.
Redis supports trivial to setup master-slave replication, with very fast non-blocking first synchronization, auto reconnection on net split, and so forth.
Fortunately, it already has client libraries for several languages: Python, PHP, Ruby, Java etc. Miguel De Icaza has already started a client library (called redis-sharp) for C#, but lacks a lot of Redis command.
Salvatore Sanfilippo has implemented a Twitter clone known as Retwis to showcase how you can use Redis and PHP to build applications without the need for a database like MySQL or any SQL query. He used PHP in order to reach a wide audience, but I also wanted to learn more about the Redist possibilities and it seemed the best idea to port the Retwis to C#/ASP.NET.
Unfortunately, the Downloads tab doesn’t contain any windows build of Redis, but you can compile your own using Cygwin. You can download my build for Redis ver. 1.2.1 stable branch from here. There is no other than to do after unpacking then start the redis-server.exe.

I don’t want to go deep in to write about the Redis protocol and commands, because you can find detailed informations in the wiki. Salvatore also published a beginner’s article based on the PHP Twitter clone he wrote. But I don’t really want to breed more of the word, click here to download the fully working Retwis example and the extended version of redis-sharp client library, it says more than a thousand words…
2 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.
Continuing the Discussion