Thursday, March 27, 2008

Monorail Custom Session Factory for Memcached

Introduction

I have written a simple but effective ICustomSessionFactory implementation that uses memcached storage on the back-end. If you don't know why you should be using memcached then you should check it out first. If you want to check out the code now, then go here. So far I think I have a passable Session Factory implementation that uses memcached on the back end. In later posts I will give some code examples and more details about deploying the Factory code.

Details

Here are a few dependencies you will need to get going:

  • Castle::Monorail
  • A memcached server or servers running on your network. Memcached is a simple and fast distributed object server for balancing object caches across many servers!
  • The latest release of Enyim. These are the guys that did all the real client work! Thanks to them for a great memcached client!
  • If you want to run the tests or plan on making modifications then you will need the Nunit/RhinoMocks stack.

Current Features

  • A session dictionary that uses memcachedon the backend. This is the real meat and potatoes.
  • Almost complete IDictionary implementation (The Values property and enumeration are not implemented). The default session in monorail doesn't seem to support the values property either. For that reason and for performance reasons I have no plans to implement the values property.
  • ICustomSessionFactory for CASTLE::MONORAIL

Planned/Missing Features

  • Optional DB persistence of sessions using activerecord/memcached fusion. Memcached storage isn't redundant and as a rule caches should be considered unreliable. I would like to give developers the option of turning on a DB persistence layer to ensure the reliability of the session state.
  • Cache provider for monorail. Abiity to easily add memcached caching into all of your service components.
  • Cache provider integration with ActiveRecord.

DOWNLOAD MEMCACHEDFORMONORAIL!

Other Memcached Goodies

I also intend to write a custom cache provider for ActiveRecord / Monorail. So stay tuned!

No comments: