For example, I have some repositories to grab some data I need:
Addressrepository.GetAddress(string para1, string para2)
UserRepository.GetUserDetail(string userName)
FinancialRepository.GetFinancialInfo(int userId)
To apply a cache aside pattern, I would like to do this:
- base on parameters passing in and some identifier for each repository, construct a key.
- Check Memory cache(or redis cache if we do down that route).
- If info can't be found or expired, call the repository function to grab data and put into cache.
Ideally I would like to write a generic helper class to do this for all data loading functions.Something like the cache aside pattern described here: http://ift.tt/2tdk1pO
However, in my case, I need to pass different parameters to different methods. In this case, is it possible to use Func and pass different parameters?
I checked msdn about this:
Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> Delegate
But how do I pass different type parameter and different number of parameters?
Aucun commentaire:
Enregistrer un commentaire