Caching? How do i do that?

Caching? How do i do that?

Old forum URL: forums.lhotka.net/forums/t/1824.aspx


Nemisis posted on Thursday, November 23, 2006

Hi everyone,
This is my first time on the website, so i hope you are all well. I have only been using CSLA for about a month now as we want to redevelop our application and CSLA just stood out as the best framework for the job!

This question maybe a little simple, so i am sorry.

I have read the book "Export VB 2005 VB Business Objects" and i have wrote most of my business objects which is perfect.

I would just like to know, how do i implement caching my business objects?  You see, i have a list of objects, which i have defined and i would like to cache them using the System.Web.Caching namespace as i have to cache this particular list for each database on the server (approx 80!!).  Most of the time, the user will login to the website and use the application from there.  But sometimes a user may use a smartclient to connect to the database, or they may even have a windows forms version of the application installed on there machine, along with there own database.  Is it possible to code for all 3 possible situations??

I really appreicate any help and i little code example if its not too much to ask for. :)

Cheers

Bayu replied on Thursday, November 23, 2006

Hi,

You can implement caching on various levels:
- within the Session of you web app you could cache an object per user and for the duration of the session;
- within the scope of your web-app you could cache objects for all users of the web-app;
- you can cache on the level of your RemotingHost or WebServicesHost and allow the same cached object to be used by all clients of the database. This assumes you configure your webapp and smartclient app to use remoting (or webservices) to acquire data.
- on the database level (in a DAL) so that all clients from whatever direction they approach your DB benefit from the same cache;

The closer to your DBs you implement the cache, the more clients are likely to benefit from cache. But also the longer the route from your clients towards your cache and the less performance benefit is acquired.

I haven't implemented caching yet, so I can't give code examples. But we plan to implement caching on the RemotingHost. All our DBs are hidden behind this host, so caching simultaneously benefits our smart client users and web app users (since both are configured to use the Remoting Host as dataportal). We have like 3-4 databases only, so even if I would have implemented it already I cannot tell if it would scale to your 80 DBs. However, the advantage is that the remotinghost can easily be run on its own dedicated machine (or cluster) so in the end it is scalable.

Implementation-wise .... have you had a look as the Cache Application Block from Microsoft already?

Regards,
Bayu

Copyright (c) Marimer LLC