views:

68

answers:

1

Hi community,

i'm not sure, where i should implement the caching in my repository pattern.

Should I implement it in the service-logic or the repositiory?

GUI -> BusinessLogic (Services) -> DataAccess (Repositories)

Thanks and best regards

+1  A: 

I would handle it in the repository/data access layer. The reasoning is because it isn't up to the business layer on where to get the data from, that is the job of the repository. The repository will then decide where to get the data from, the cache (if it's not too old) or from the live data source based on the circumstances of the data access logic.

It's a data access concern more than a business logic issue.

KallDrexx
Thanks for the answer!I think it's also better for implementation lazy loading.
Beni