Created
November 1, 2010 10:01
-
-
Save robcthegeek/657924 to your computer and use it in GitHub Desktop.
DDD Style Repository Implementation (Cache Wrapper)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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