Monday, 19 March 2012

Redis and MemCached with C#

Here are a couple of simple C# examples for Redis and MemCached. 

Please note, the Redis server included in this example should not be used in production code.

Dummy data


I use a factory method to create a number of clients with a number trades, which then get written to and read from Redis and MemCached.




To run the Redis and MemCached servers included in the source code below, with default settings just run each executable:

  • \Redis-Server\redis-server.exe
  • \MemCached-Server\memcached.exe

Both Redis and MemCached are designed to be distributed over multiple machines.  Bear in mind, Redis with the default settings persists the data to disk, which you can turn off, whereas MemCached is purely in memory.

The above code examples have been altered to display purely the relevant code for interacting with Redis and MemCache.  The source code below contains additional code such as writing to the console window and making use of the stopwatch.

Source code:

No comments:

Post a Comment