Adds a new cache rule for the specified Type with the specified settings.
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.
Assembly: TechTalk.Genome (in TechTalk.Genome.dll)
Editions: Professional, Evaluation, Express