Since the project is useful to the knowledge of cache, here is a summary.
Run aspnet_regsql-c "Server = (local) \ tadb; database = abico; uid = sa; Pwd ="-ed-et-T "events" in the vs2008 VC window"
A aspnet_sqlcachetablesforchangenotification table will be created in your database, and there are several stored procedures.
Configure the cached information in Web. config.
Configuration Information
<Appsettings/>
<Connectionstrings>
<Add name = "testcache" connectionstring = "Data Source = 127.0.0.1; initial catalog = abico; user id = sa; Password = 135246" providername = "system. Data. sqlclient"/>
</Connectionstrings>
Code
<System. Web>
<Caching>
<Sqlcachedependency enabled = "true" polltime = "1000">
<Databases>
<Add name = "abico" connectionstringname = "testcache"/>
</Databases>
</Sqlcachedependency>
Polltime indicates the database polling time. The default value is 1 minute, in milliseconds. This parameter is very important. Similar to the timer function, the application will periodically poll your database based on this time to check whether your table has been updated.
If it is not configured in Web. config, you can also write it in the sqlcachedependencyadmin class.
To Cache multiple tables:
1) In the aspnet_sqlcachetablesforchangenotification table, a new record tabname is the table you want to cache.
2) sqlcachedependencyadmin. enabletablefornotifications (constring, "qx_user"); the first parameter is the connection string, and the second parameter is the name of the table to be cached.
The main point is that you need to write the table name for your cache dependency.
Sqlcachedependency Dep = new sqlcachedependency ("abico", "qx_user"); abico: Database Name, qx_user: Table name.
------------------------------------------------------
The cache I understand is that. Net makes a timer to poll the database according to the polltime, calls the stored procedure, and knows the aspnet_sqlcachetablesforchangenotification information of the table, which contains the changeid. When the changeid changes, the callback function is triggered if a callback function exists. If no, the existing cache is deleted.
-------------------------------------------------------
Demo download/files/86188281/cachetest.rar