Are there any code examples that would explain the best practice to implement a global caching layer on top of the repository. I'm using the WCF plain Service in my solution.
1 Answer, 1 is accepted
0
Viktor Zhivkov
Telerik team
answered on 26 Dec 2012, 08:26 PM
Hi Daniel,
Unfortunately there is not code sample that demonstrates how to create caching repository with OpenAccess.
One important thing that you should consider is that OpenAccess has build-in cache mechanisms:
Level 1 - Embedded in the OpenAccess context instance - caches entity instances during the lifetime of the context. Enabled by default.
Level 2 - Shared between all OpenAccess context instances. By default it is disabled. You can find more about Level 2 cachinghere.
If the out of the box caching is not enough, you can implement the caching mechanism inside a custom repository class that is used as base for all concrete per entity repositories.
Or you can implement caching of the DTO objects on service or assembler level.
The decision on which layer to implement it is completely yours and depends on your application architecture.
Either way after you have set on certain implementation I advice you to create a dedicated T4 template to be used in Add OpenAccess Service wizard in order to minimize repetitive tasks of changing generated code after each run of the wizard. You can follow the steps in this tutorial in order to create a custom code generation template and enable automatic custom template discovery in the wizard.
If you need any further assistance implementing custom cache or you need more information about Level 1 and 2 build-in cache implementation, do not hesitate to contact us.
Kind regards,
Viktor Zhivkov
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.