Exemple #1
0
        private IEnumerable <CacheTokenPair> GetDependentTokenPairs(string typeName, string codename, Func <CacheTokenPair, IEnumerable <CacheTokenPair> > dependencyFactory)
        {
            foreach (var dependentTypeName in KenticoCloudCacheHelper.GetDependentTypeNames(typeName))
            {
                return(dependencyFactory(new CacheTokenPair(dependentTypeName, codename)));
            }

            return(null);
        }
Exemple #2
0
 /// <summary>
 /// Invalidates (clears) a cache entry.
 /// </summary>
 /// <param name="cacheTokenPair">Identifiers of the entry.</param>
 public void InvalidateEntry(string typeName, string codename)
 {
     foreach (var dependentTypeName in KenticoCloudCacheHelper.GetDependentTypeNames(typeName))
     {
         if (_memoryCache.TryGetValue(string.Join("|", DUMMY_IDENTIFIER, dependentTypeName, codename), out CancellationTokenSource dummyEntry))
         {
             // Mark all subscribers to the CancellationTokenSource as invalid.
             dummyEntry.Cancel();
         }
     }
 }