5 votes

UmbCacheDependencies

What does this do?

Ever wanted to throw something into the .net cache but worried about it containing stale data from Umbraco? This package ensures your objects are flushed from the .net cache when the associated umbraco content items are updated.

How Do I use it?

Simples ;)

HttpContext.Current.Cache.Add(
    "key",
    "value", 
    new UmbracoDependency(
	// tickles cache only when document 1234 is updated.
        new ContentDependency(1234), 

	//tickles cache when document 1234 and its children are updated.
        new ContentDependency(1234,true), 

	//tickles cache when any document of document type 1235 is updated.
        new AllContentOfTypeDependency(1235), 

	//tickles cache when any document of document type docTypeAlias is updated.
        new AllContentOfTypeDependency("docTypeAlias"),

	//tickles cache when any media item of media type 124 is updated.
        new MediaDependency(124),

	//tickles cache when any media of media type 1032 is updated.
        new AllMediaOfTypeDependency(1032)
    ), 
    Cache.NoAbsoluteExpiration,
    Cache.NoSlidingExpiration, 
    CacheItemPriority.Normal, 
    null
);

You can list as many Dependencies as you wish.

Currrent dependencies are as follows:

  • ContentDependency - Requires a node ID to tie to, if that content item gets updated, then the cache is flushed. Has an optional parameter of catchChildren, this will make the cache expire if any children of the specified node are edited.
  • MediaDependency - Requires a media ID to tie to, if that content item gets updated, then the cache is flushed for that item.
  • AllMediaOfTypeDependency - Requires a node ID of a media type. If any media items of that type are changed, then the cache is flushed.
  • AllContentOfTypeDependency - Requires a node ID of a document type or an alias. If any documents of that type are changed, then the cache is flushed.

Screenshots

Package owner

Stephen Roberts

Stephen Roberts

Stephen has 516 karma points

Package Compatibility

This package is compatible with the following versions as reported by community members who have downloaded this package:
Untested or doesn't work on Umbraco Cloud
Version 8.18.x (untested)

You must login before you can report on package compatibility.

Previously reported to work on versions:

Package Information

  • Package owner: Stephen Roberts
  • Created: 01/07/2014
  • Current version 1.0.0
  • License MIT
  • Downloads on Our: 465