Chili.Opf3 Send comments on this topic.
SimpleCacheManager Class
See Also  Members   Example 
Chili.Opf3.Caching Namespace : SimpleCacheManager Class




Class that implements a simple caching algorithm.

Syntax

Visual Basic (Declaration) 
Public Class SimpleCacheManager 
   Inherits CacheManagerBase
   Implements ICacheManager 
Visual Basic (Usage)Copy Code
Dim instance As SimpleCacheManager
C# 
public class SimpleCacheManager : CacheManagerBase, ICacheManager  
Managed Extensions for C++ 
public __gc class SimpleCacheManager : public CacheManagerBase, ICacheManager  
C++/CLI 
public ref class SimpleCacheManager : public CacheManagerBase, ICacheManager  

Example

The following example shows how to set the SimpleCacheManager.
C#Copy Code
// Creates a new ObjectContext that uses an MsSql Server as storage. 
ObjectContext context = new ObjectContext(new MsSqlStorage("sa", "",  
    "localhost", "application")); 
// Set the CacheManager. 
SimpleCacheManager cache = new SimpleCacheManager(); 
context.CacheManager = cache; 
// Extend the cache duration of a persistent if requested a second time. 
// Basically reset the expiration timer for that persistent. 
cache.ExtendDurationOnRequest = true; 
 
// Set the default duration for a persistent to 10 seconds. 
cache.PersistentsDefaultDuration = new TimeSpan(10000); 
// Set the default duration for a query to 20 seconds. 
cache.QueriesDefaultDuration = new TimeSpan(20000); 
 
// ... Other code. 
 
// Clear all persistents that are cached. 
cache.ClearPersistents(); 
 
// Clear also all queries that are cached. 
cache.ClearQueries(); 
    

Remarks

Thread Safety: This class is thread safe.

This class implements a simple caching algorithm. This algorithm uses internally a weak references cache that holds instances of persistent objects. The instances are hold as long in the cache as long they exist in the current AppDomain (in simple words: in the current process). If the instances have been collected by the GC they are also removed from this cache.

To have persistent objects cached by the SimpleCacheManager they need to be decorated with the SimpleCacheAttribute. All persistent without that attribute, are not cached!

Inheritance Hierarchy

System.Object
   Chili.Opf3.Caching.CacheManagerBase
      Chili.Opf3.Caching.SimpleCacheManager

Requirements

Namespace: Chili.Opf3.Caching

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: Chili.Opf3 (in Chili.Opf3.dll)

See Also