R
Ravi
Hi,
We are planning to use SqlCacheDepency in our application(ASP.Net2.0/SQL
Server 2005).I was just doing a POC and found the Cache addition and
invalidation is behaving abnormally. I just wanted to know where its going
wrong.
I have a command object as dependency. The stored proc. returns result set
based on filter param. Basically its simple select <col1>,<col2> from
dbo.<tablename> where id = <param>. When I add a object into cache with the
above dependency cmd I can see the Cache object is still empty but a
notification entry in SQL 2005(select * from sys.dm_qn_subscriptions). But
sometimes there is an entry in ASP cache object but no notification entry in
SQL 2005. Why is it behaving strangely? I have re-produced this after
restarting IIS and clearing sql of all notifications.
Can some one help me on this?
sample code:
bool blnDepend =
System.Data.SqlClient.SqlDependency.Start("uid=<>;pwd=<>;data
source=(local);initial catalog=<>;");
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "dbo.GetAllTasks";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@TNAME", SqlDbType.NChar, 10);
cmd.Parameters["@TNAME"].Value = "T1";
cmd.Prepare();
System.Web.Caching.CacheDependency sqldependency = new
System.Web.Caching.SqlCacheDependency(cmd);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
object o = HttpContext.Current.Cache.Add("T1", "hello",
sqldependency, System.Web.Caching.Cache.NoAbsoluteExpiration,
System.Web.Caching.Cache.NoSlidingExpiration,
System.Web.Caching.CacheItemPriority.Normal, null);
We are planning to use SqlCacheDepency in our application(ASP.Net2.0/SQL
Server 2005).I was just doing a POC and found the Cache addition and
invalidation is behaving abnormally. I just wanted to know where its going
wrong.
I have a command object as dependency. The stored proc. returns result set
based on filter param. Basically its simple select <col1>,<col2> from
dbo.<tablename> where id = <param>. When I add a object into cache with the
above dependency cmd I can see the Cache object is still empty but a
notification entry in SQL 2005(select * from sys.dm_qn_subscriptions). But
sometimes there is an entry in ASP cache object but no notification entry in
SQL 2005. Why is it behaving strangely? I have re-produced this after
restarting IIS and clearing sql of all notifications.
Can some one help me on this?
sample code:
bool blnDepend =
System.Data.SqlClient.SqlDependency.Start("uid=<>;pwd=<>;data
source=(local);initial catalog=<>;");
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "dbo.GetAllTasks";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@TNAME", SqlDbType.NChar, 10);
cmd.Parameters["@TNAME"].Value = "T1";
cmd.Prepare();
System.Web.Caching.CacheDependency sqldependency = new
System.Web.Caching.SqlCacheDependency(cmd);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
object o = HttpContext.Current.Cache.Add("T1", "hello",
sqldependency, System.Web.Caching.Cache.NoAbsoluteExpiration,
System.Web.Caching.Cache.NoSlidingExpiration,
System.Web.Caching.CacheItemPriority.Normal, null);