TechTalk Genome v4.2

QueryCacheManager.Invalidate Method (IContext, Set)

Invalidates the cached items of the set in the context.

public static void Invalidate(
   IContext context,
   Set s
);

Parameters

context
The context stores the cached values. The context stores the cached values.
s
The cached Set. The cached Set.

Example

          
using(Context.Push(LocalContext.Create()))
{
    Set cages = dataDomain.Extent(typeof(Cage))["Size > 2"];
    cages = QueryCacheManager.CacheSet(cages);

    // these operations are served from memory
    if (cages.Count == 0)
       Console.WriteLine("No cages found.");
    else 
    {    
        foreach (Cage cage in cages)
        {
            Console.WriteLine("Cage: {0}", cage);
        }
    }
}
                

Invalidating the query cache manually

            
using(Context.Push(ShortRunningTransactionContext.Create()))
{
    Set cages = dataDomain.Extent(typeof(Cage))["Size > 2"];
    cages = QueryCacheManager.CacheSet(cages);

    ... //display the cached set

    if (cages.Count > 0)
    {
        // modifying a cage size
        Cage cage = (Cage)cages.GetItem(0);
        cage.Size = 1;
        // we need to invalidate the query cache to see the updated result
        QueryCacheManager.Invalidate(cages);
        
        Console.WriteLine("Number of cages after modification: {0}", cages.Count);
    }
}
                
          
using(Context.Push(LocalContext.Create()))
{
    Set cages = dataDomain.Extent(typeof(Cage))["Size > 2"];
    cages = QueryCacheManager.CacheSet(cages);

    // these operations are served from memory
    if (cages.Count == 0)
       Console.WriteLine("No cages found.");
    else 
    {    
        foreach (Cage cage in cages)
        {
            Console.WriteLine("Cage: {0}", cage);
        }
    }
}
                

Invalidating the query cache manually

            
using(Context.Push(ShortRunningTransactionContext.Create()))
{
    Set cages = dataDomain.Extent(typeof(Cage))["Size > 2"];
    cages = QueryCacheManager.CacheSet(cages);

    ... //display the cached set

    if (cages.Count > 0)
    {
        // modifying a cage size
        Cage cage = (Cage)cages.GetItem(0);
        cage.Size = 1;
        // we need to invalidate the query cache to see the updated result
        QueryCacheManager.Invalidate(cages);
        
        Console.WriteLine("Number of cages after modification: {0}", cages.Count);
    }
}
                

Requirements

Namespace: TechTalk.Genome

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

Version: 4.2.4.4

Editions: Professional, Evaluation, Express

See Also

QueryCacheManager Class | TechTalk.Genome Namespace | QueryCacheManager.Invalidate Overload List | !:CacheSet(Context, Set) | PredictiveCacheManager.PrecacheSet | Invalidate | !:CacheSet(Context, Set) | PredictiveCacheManager.PrecacheSet | Invalidate