Skip to content

Instantly share code, notes, and snippets.

@robcthegeek
Created November 1, 2010 10:01
Show Gist options
  • Save robcthegeek/657924 to your computer and use it in GitHub Desktop.
Save robcthegeek/657924 to your computer and use it in GitHub Desktop.
DDD Style Repository Implementation (Cache Wrapper)
public interface ICustomerRepository
{
Customer RetrieveById(string id);
}
public class CustomerSessionCacheRepository(ICustomerRepository innerRepository) : ICustomerRepository
{
public Customer RetrieveById(string id)
{
if (_cache.Contains(id))
return _cache[id];
else
{
var data = innerRepository.RetrieveById(id);
_cache[id] = data;
return data;
}
}
}
public class CustomerSessionCacheRepository()
{
public Customer RetrieveById(string id)
{
// NHibernate Magic to get the record...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment