Skip to content

Instantly share code, notes, and snippets.

@mskutta
Created April 17, 2015 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mskutta/38197077e260df9885cd to your computer and use it in GitHub Desktop.
Save mskutta/38197077e260df9885cd to your computer and use it in GitHub Desktop.
Caching parsed MediaItem using Sitecore revision
private static List<Price> _prices;
private static string _pricesRevision;
private static readonly object _lock = new object();
public static List<Price> GetPrices(MediaItem mediaItem)
{
var revision = mediaItem.Statistics.Revision;
if (revision != _pricesRevision)
{
lock (_lock)
{
if (revision != _pricesRevision)
{
_prices = ReadPrices(mediaItem);
_pricesRevision = revision;
}
}
}
return _prices;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment