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 511 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.8.x (untested)
Version 8.7.x (untested)
Version 8.6.x (untested)
Version 8.5.x (untested)
Version 8.4.x (untested)
Version 8.3.x (untested)
Version 8.2.x (untested)
Version 8.1.x (untested)
Version 8.0.x (untested)
Version 7.15.x (untested)
Version 7.14.x (untested)
Version 7.13.x (untested)
Version 7.12.x (untested)
Version 7.11.x (untested)
Version 7.10.x (untested)
Version 7.9.x (untested)
Version 7.8.x (untested)
Version 7.7.x (untested)
Version 7.6.x (untested)
Version 7.5.x (untested)
Version 7.4.x (untested)
Version 7.3.x (untested)
Version 7.2.x (untested)
Version 7.1.x (untested)
Version 7.0.x (untested)
Version 6.2.x (untested)

You must login before you can report on package compatibility.

Package Information

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