/// <summary> /// Clears the given <paramref name="record"/> from the <paramref name="cachingService"/>. /// </summary> /// <param name="record">The <see cref="Record"/> which should be cleared from the cache.</param> /// <param name="context">The <see cref="IMansionContext"/>.</param> /// <param name="cachingService">The <see cref="ICachingService"/>.</param> /// <exception cref="ArgumentNullException">Thrown if one of the parameters is null.</exception> public static void ClearFromCache(this Record record, IMansionContext context, ICachingService cachingService) { // validate arguments if (record == null) throw new ArgumentNullException("record"); if (context == null) throw new ArgumentNullException("context"); if (cachingService == null) throw new ArgumentNullException("cachingService"); // fire the evict by ID cachingService.Clear(record.CalculateIdCacheKey()); // fire the evict by tree ID, if any NodePointer pointer; if (record.TryGet(context, "pointer", out pointer)) { foreach (var treeCacheKey in pointer.CalculateTreeIdCacheKeys()) cachingService.Clear(treeCacheKey); } // fire the repository modified cachingService.Clear(CachingRepositoryDecorator.RepositoryModifiedDependency.Key); }
/// <summary> /// Clears the given <paramref name="node"/> from the <paramref name="cachingService"/>. /// </summary> /// <param name="node">The <see cref="Node"/> which should be cleared from the cache.</param> /// <param name="cachingService">The <see cref="ICachingService"/>.</param> /// <exception cref="ArgumentNullException">Thrown if one of the parameters is null.</exception> public static void ClearFromCache(this Node node, ICachingService cachingService) { // validate arguments if (node == null) throw new ArgumentNullException("node"); if (cachingService == null) throw new ArgumentNullException("cachingService"); // fire the evict by ID cachingService.Clear(node.CalculateIdCacheKey()); // fire the evict by tree ID foreach (var treeCacheKey in node.Pointer.CalculateTreeIdCacheKeys()) cachingService.Clear(treeCacheKey); // fire the repository modified cachingService.Clear(CachingRepositoryDecorator.RepositoryModifiedDependency.Key); }
/// <summary> /// Clears this instance. /// </summary> public static void Clear() { cacheService.Clear(); }