TechTalk Genome v4.2

CacheConfiguration.Add Method 

Adds a new cache rule for the specified Type with the specified settings.

public void Add(
   Type type,
   ICacheFactory cache,
   bool share,
   bool storeShared,
   bool acceptShared,
   SharingMode sharingMode
);

Parameters

type
The Type to which the new cache rule should apply. Cache rules are also inherited by derived classes if no explicit rule is defined for the derived class.
cache
An object implementing ICacheFactory identifying the cache used to store state for objects of the specified type. If you use the same cache object to add cache rules to the same CacheConfiguration instance for different types, objects of those types will share the same cache.
share
Specifies whether the Context should share state information for objects with the specifed type with its BaseContext. Wether the BaseContext will store the shared information depends on its storeShared setting for the type of the shared object.
storeShared
Specifies whether the Context should store state information received for objects with the specifed type from its descendant Contexts.
acceptShared
Specifies whether the Context should accept state information for objects of the specifed type from its BaseContext when the state of an object is retreived. If set to false and the object state is not available in the Context, the object will be retreived from the database.
sharingMode
Specifies how the Context should store state information when it is also shared with other Contexts.

Remarks

Use the Add method to add cache rules to the CacheConfiguration before passing it to one of the Context creation methods.

Cache rules describe various aspects of object state storage for a given Context including the cache interactions between base and descendant Contexts.

When the state of a persistent object is needed in a given Context, the Context will first look for it in its own cache. If the requested state cannot be found there and the cache rule for the type of the object is configured with acceptShared=true, the request is propagated up the Context hierarchy until the state is found or the top of the hierarchy is reached. If the object state could still not be found, it will be retrieved from the database. If acceptShared is set to false, the request will never be propagated up the Context hierarchy and the state will be retreived from the database if not found in the Context's own cache.

When an object state is retrieved from the database in a given Context, the share parameter of the caching rule for the type of the object is checked. If it is set to true, the object state will be propagated up the Context hierarchy until either the to of the hierarchy or a Context configured with share=false for the type of object is reached. Which Context will eventually store the object state also depends on the value storeShared parameter in each Context in the Context hierarchy for the type of the object: the Context highest in the hierarchy receiving the object state with a storeShared value of true.

The sharingMode parameter influences the data consistency of the Context. Setting it to SharingMode.CreateCopy will ensure that when the Context receives an object state (either by retrieving it from the database or receiving it from a base or descendant Context), it will store its own copy of the state and will see the same object state as long as the object is not removed from the Context (either because cache size constraints or invalidation). If sharingMode is set to SharingMode.CreateReference, the object state seen by the Context could be actually stored in another Context and can change unexpectedly. Reference storage is actually just a performance enhancement ensuring that the Context hierarchy doesn't have to traversed each time the object state is requested.

Requirements

Namespace: TechTalk.Genome

Assembly: TechTalk.Genome (in TechTalk.Genome.dll)

Version: 4.2.11.59

Editions: Professional, Evaluation, Express

See Also

CacheConfiguration Class | TechTalk.Genome Namespace