This is a migrated thread and some comments may be shown as answers.

Implementing a global Cache on top of repository (WCF Plain Service)

1 Answer 72 Views
Web Services
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Daniel Frumkin
Top achievements
Rank 1
Daniel Frumkin asked on 22 Dec 2012, 01:42 AM
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

Sort by
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 caching here.
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.
Tags
Web Services
Asked by
Daniel Frumkin
Top achievements
Rank 1
Answers by
Viktor Zhivkov
Telerik team
Share this question
or