質問

I am trying to Cache a few data objects, which are used very frequently and thus are queried very often loading the db server. However these do not change that frequently, making them good candidates for caching.

However, whenever they are changed I do want the change to reflect as soon as possible, thus I thought of using a SqlCacheDependency.

SqlCacheDependency dependency = new SqlCacheDependency(cacheDependencyCmd);

dependency.OnChange += new OnChangeEventHandler(SqlDependency_OnChange);

However, I am getting the following error in Visual Studio

Visual Studio Error Tip

I checked and realized that everywhere people seemed to have used SqlDependency rather than SqlCacheDependency. Why has OnChange Event been left out of SqlCacheDependeny? Is bad for performance? Or am I just missing something very basic here.

役に立ちましたか?

解決

As I mentioned in my comment above,

Ok, my thought now is that it has been left out because the ASP.NET Cache has the ItemRemovedCallBack and that is where one should write code to handle the Dependency.OnChange as the behavior is supposed to be that the Cache gets invalidated when the dependency changes.

I think this is the answer to the question

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top