开发者

how to cache a dataset when database table being update

I need to use caching in my project. The problem is that, When page is firstly load ı cached a dataset. Then after after I update or insert a new record in table. my dataset returns from the cached records. The question is that, How can i update cache values when the table is being changed in da开发者_C百科tabase


This is the classic problem of caching - cash refresh and expiry. The answer is that it depends on how much of an issue it is have stale data. If it's critical not to then don't cache. Otherwise you can update the cache by having a trigger (for example in the db or the db writer) that raises and event that a listener will catch an issue a refresh asynchronously.

http://simple.wikipedia.org/wiki/Cache_algorithm


You should use SQL cache dependency. This will ensure that the cache item is invalidated once the changes occur in the database.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜