Write-Through Cache
I am trying to do an C# implementation of Write-through Cache to minimize the read hits on db i need your suggestions, articles or sample codes to fulfill this assignment.
Initially this would be use only on o开发者_开发技巧ne server but will be updated to work in clustered environment.
I only able to get a worth reading article on Oracle Site.
Please share your views
Regards Mubashar
The easiest thing to do would be to cache at a higher level than the database-connectivity level. If you have a data access layer that encapsulates you from the nitty-gritties of SQL, that's usually a good place. If you have a place where data objects are requested, that would be even better; your caching key can be the identity of those objects.
What you ultimately will probably want is a caching Proxy which encapsulates your caching logic, interdicting reads but passing writes through to the underlying service (the object persistence layer or the data access layer). You can use WeakReference
to cause unused objects to expire out of your caching collection, in which case you'll need to do just a little bit of clean up. On the other hand you can write your own expiration logic, in which case you have to do more clean up but will retain more control.
Without more specific details, it's hard to give you a specific answer.
精彩评论