Last post Oct 03, 2007 02:03 PM by OldPheart
Sep 27, 2006 10:08 PM|Harold.NET|LINK
ok so they didn't add the functionality for the sql dependencies and notifications into the enterprise library, so this is what i came up with so far as a wrapper:
public class SqlExpiration : Microsoft.Practices.EnterpriseLibrary.Caching.ICacheItemExpiration, IDisposable
private SqlCacheDependency dp = null;
private string database = string.Empty;
private string table = string.Empty;
public SqlExpiration(string database, string table)
this.table = table;
this.database = database;
dp = new SqlCacheDependency(database, table);
#region ICacheItemExpiration Members
public bool HasExpired()
public void Initialize(Microsoft.Practices.EnterpriseLibrary.Caching.CacheItem owningCacheItem)
public void Notify()
#region IDisposable Members
public void Dispose()
if (dp != null)
am i missing anything? it seems to work fine i just have no idea
Feb 18, 2007 05:22 AM|pure.krome|LINK
very interesting indead!!! I like using the EntLibrary Caching service in my custom Data Access Layer instead of the web cache (which all the examples and people say to use) because i feel like it's tightly binding http web stuff to a reusable component
(assembly) that might not be doing any web stuff. Pedantic, i know ... but it's the principle, for me at least.
That said, i stumbled across this post and it has me VERY interested. I'm about to try this out ... but i was curious to see if you ended up using this in any projects? you said 'It seems to work fine' ... but can u elaborte on that - ie. The cache items
get wiped/zapped when a database table gets updated -- proving that the sqlnotification broker stuff is working.
also, did u setup your stuff using the asp_regsql.exe command?
Please reply - very very intersted :)
oh, ps. your two database and name fields are redundant - not required.
Feb 18, 2007 03:27 PM|Harold.NET|LINK
Yes, I used the reqsql command and all.
It is working great for my projects, I see no issues at all with anything.
Feb 19, 2007 04:07 AM|pure.krome|LINK
1) Why did u use the aspnet_regsql.exe command? what functionality does it do, which you are required to use?
2) Why did u go with using the EntLibrary's Caching component instead of using the http caching stuff which most people suggest using? The reason i ask this is because I don't want to use the Asp caching object thing because i'm doing my caching in a Data
Access Layer and it seems silly to put web stuff in there when the reusable assembly might not be doing any web stuff at all (eg a winform app) .. even though the System.Web... namespace stuff works fine in a winform ... and the SqlCacheDependency class is
found in System.Web.... or something.
Oct 03, 2007 02:03 PM|OldPheart|LINK
Have you used this in a farm/clustered environment? We ran across a problem with caching in sql server for a couple reasons. 1) I wasn't specifying an expiration so the artifacts remained in cache indefinitely and 2) when a server in the cluster reset,
caching would blow chunks until a manual delete was issued for the tables that stored the cached artifacts.