Using the Global Cache in Express Edition
Using the global cache is almost completely automatic. By default, a C1WebExpressConnection component has CacheMode = InWebForms, which means that it uses the global cache.
To disable caching, set CacheMode = NotCached.
You may need to specify cache properties for global cache tuning. This is done in the CacheProperties property. If you select CacheStorage = File (default), especially in production settings, you may want to increase the value of the MaxCount, 50 by default, limiting the number of data set instances in the cache.
With CacheStorage = File, you will usually set the CacheStoragePath property to point to a directory where you will store cache files. If you use a multi-server configuration (Web farm), you must include a server name in the path to ensure that all cache files are stored on the same server (usually called state server). If you fail to provide a server name, data will be cached on the server that is serving the current user request. That can cause data inconsistency when requests are assigned to different servers. By default, if you leave CacheStoragePath empty, the temporary directory of the current server is used.
If you use ChangesCacheStorage = File, you will also usually set the ChangesCacheStoragePath property to specify a directory where you store files containing saved user data modifications. This is a part of the global cache necessary if users are allowed to modify data. The same considerations regarding server name in the path apply to ChangesCacheStoragePath as to CacheStoragePath.
Other than tuning cache properties, which is optional, the global cache works automatically. It is used every time you call C1WebExpressConnection.Fill. Filling the data set, C1WebDataObjects first looks for data in the cache and performs database fetch only if it is not found in the cache.
The only additional code you must include in your application to support global is one line in your Global.aspx file:
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
GlobalCache.DeleteFiles(Me)
End Sub
• C#
protected void Application_End(Object sender, EventArgs e)
{
GlobalCache.DeleteFiles(this);
}
This is necessary to clean up the cache files when your application is shut down. It is necessary only if you use CacheStorage = File, but it is a good idea to always call this method in the Application_End event.
|