I can create a SqlCacheDependency, and link it to a cached item in httpcontext cache. When something change, it will remove the cached item from the cache. I think I have to redo the process when that happens - prepare sql command, create SqlCacheDependency and insert the item into cache. Now I only need a notification from my SQL when something changes in one of my table, I don;t need read anything from db, and I think I should find a way to not recreate the SqlCacheDependency object everytime?
any suggestion?
Maybe you need a update/insert trigger that raise an error. For example, if you want to get notification when something changes in t1, you can use such T-SQL command to create a trigger:
create trigger trg_t1 on t1 for update,insert,delete
as
RAISERROR ('Some change has been made to table t1',16, 1)
go
To learn more about RAISERROR command, please take a look at:
http://msdn.microsoft.com/library/en-us/tsqlref/ts_ra-rz_5ooi.asp?frame=true
And for triggers you can start from here:
http://msdn.microsoft.com/library/en-us/createdb/cm_8_des_08_116g.asp?frame=true
|||I am not sure what the trigger you described can help in my case. What I need is a way to let DB notify ASP when something change, the change is made by other ASP httphandlers, so those change should go on without interrupt. Once the change is done, it should notify ASP, which will invalid the data that cached with SQLCacheDependency. The problem what I have is once that happens, the SQLCacheDepency object will be removed, I need recreate it again. I think it is unnecessory, since I only need a notification from DB.
No comments:
Post a Comment