Created
April 17, 2015 18:54
-
-
Save mskutta/38197077e260df9885cd to your computer and use it in GitHub Desktop.
Caching parsed MediaItem using Sitecore revision
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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