Ca4nul @ facebook Ca4nul @ Twitter
Forum announcement: $$ Top Contributors Contest (March 2010) - Win Instant extra Cash $$
Welcome Guest Search | Active Topics | Members | Log In | Register

SQL Cache Dependency Options
richard
Posted: Friday, August 28, 2009 3:42:29 AM
Rank: Advanced Member
Groups: Member

Joined: 6/9/2008
Posts: 149
Points: 447
Location: California, USA
Hi,

I am working on an application where we use caching extensively. I have a small problem with the caching part. I am trying to use SQLCacheDependency on my cache objects. To give you a brief, we cache the items groupwise based on projects. So i will have more than one cache object for a particular group and likewise for other groups. My requirement is that, if i edit one particular group, i would want to clear the cache items of only that group. When i tried implementing SQLCacheDependency, i was getting the following error

An attempt was made to reference a "CacheDependency object from more than one Cache entry". I am working on creating a file based dependency, but if theres something that can be done to make the SQLCacheDependency, it would be great. I am also attaching the code snippet for the same.
Code:
using (SqlConnection cn = new SqlConnection(m_ConnectionString))

{
m_CommandString = " < Query > ";

cn.Open();
using (SqlCommand cm = new SqlCommand(m_CommandString, cn))

{
SqlCacheDependency dep = new SqlCacheDependency(cm);

SqlDataAdapter da = new SqlDataAdapter(cm);
DataTable dt1 = new DataTable();

DataTable dt2 = new DataTable();

da.Fill(dt1);da.Fill(dt2);
Cache.Insert("Group 1", dt1, dep);

Cache.Insert("Group 2", dt2, dep); //   I get the error in this line

}

}


Thanks in advance
Sponsor
Posted: Friday, August 28, 2009 3:42:29 AM
adam
Posted: Friday, August 28, 2009 3:45:08 AM
Rank: Advanced Member
Groups: Member

Joined: 4/3/2008
Posts: 142
Points: 432
Location: London
HI, richard:

I have not found some approach to make one SqlCacheDependency relate to multiple cache entries. However, i want to recommend you to organize your several cache entries into one collection or one array and relate it with one SqlCacheDependency.

If i misunderstand you about your question, please feel free to correct me and i will try to help you with more information.

I hope the above information will be helpful. If you have any issues or concerns, please let me know. It's my pleasure to be of assistance
johnpatrick
Posted: Thursday, February 25, 2010 2:21:21 AM
Rank: Newbie
Groups: Member

Joined: 2/25/2010
Posts: 3
Points: 9
Location: uk
richard wrote:
Hi,

I am working on an application where we use caching extensively. I have a small problem with the caching part. I am trying to use SQLCacheDependency on my cache objects. To give you a brief, we cache the items groupwise based on projects. So i will have more than one cache object for a particular group and likewise for other groups. My requirement is that, if i edit one particular group, i would want to clear the cache items of only that group. When i tried implementing SQLCacheDependency, i was getting the following error

An attempt was made to reference a "CacheDependency object from more than one Cache entry". I am working on creating a file based dependency, but if theres something that can be done to make the SQLCacheDependency, it would be great. I am also attaching the code snippet for the same.
Code:
using (SqlConnection cn = new SqlConnection(m_ConnectionString))

{
m_CommandString = " < Query > ";

cn.Open();
using (SqlCommand cm = new SqlCommand(m_CommandString, cn))

{
SqlCacheDependency dep = new SqlCacheDependency(cm);

SqlDataAdapter da = new SqlDataAdapter(cm);
DataTable dt1 = new DataTable();

DataTable dt2 = new DataTable();

da.Fill(dt1);da.Fill(dt2);
Cache.Insert("Group 1", dt1, dep);

Cache.Insert("Group 2", dt2, dep); //   I get the error in this line

}

}


Thanks in advance



thanks its goods

History Essay
How to Write An Essay
How to Write Essay
Student Essays
Link Exchange Blog
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

ASPNET Theme created by Boskone (Dan Ferguson)
Powered by Ca4nul.Com
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.119 seconds.