Using Redis on Windows with ServiceStack
Posted on 03. Apr, 2012 by clippersoft in Blog, Coding
While Redis is well supported on *nix platforms, its not so much on Windows. As I plan on utilizing .net and SQL server, I need to use something that works in Windows. I tried using Couchbase’s version of memcached, but never got it working properly through ServiceStack’s memcached add-on. Plus, the install seemed very heavy for my currently simple needs to cache some data during user login.
So, I hit Google to find a Redis on Windows solution. I first came across this one…
https://github.com/dmajkic/redis/downloads
…which is nice, but is not service based. I wanted something that will run as a Windows service and came across this fork…
…which installs the redis port as a Windows service.
Now in my asp.net mvc site, in the ServiceStack App_Start in the container, I can register it as the Cache client…
container.Register
container.Register
Now in my base controller, I specified…
public ICacheClient CacheClient { get; set; }
protected override void OnAuthorization(AuthorizationContext filterContext) {
using (CacheClient) {
string cacheAccountKey = IdUtils.CreateUrn
AccountModel account = CacheClient.Get
// ...
}
…which now goes against the Redis server.
I don’t know how stable it is yet, and whether I would consider this for a production site, but given the few Windows options, I might not have a lot of choices. Thanks to ServiceStack, Redis, and the folks who helped port it to Windows to at least get me this far
.
