Rename GetOrAdd to GetOrSet.

This commit is contained in:
Chris Ross 2014-09-25 16:34:25 -07:00
parent 6d9bc21e83
commit 6f7560e33b
3 changed files with 3 additions and 3 deletions

View File

@ -65,7 +65,7 @@ namespace MusicStore.Areas.Admin.Controllers
public IActionResult Details(int id)
{
string cacheId = string.Format("album_{0}", id);
var album = cache.GetOrAdd(cacheId, context =>
var album = cache.GetOrSet(cacheId, context =>
{
//Remove it from cache if not retrieved in last 10 minutes
context.SetSlidingExpiration(TimeSpan.FromMinutes(10));

View File

@ -21,7 +21,7 @@ namespace MusicStore.Components
public async Task<IViewComponentResult> InvokeAsync()
{
var latestAlbum = await cache.GetOrAdd("latestAlbum", async context =>
var latestAlbum = await cache.GetOrSet("latestAlbum", async context =>
{
context.SetAbsoluteExpiration(TimeSpan.FromMinutes(10));
return await GetLatestAlbum();

View File

@ -23,7 +23,7 @@ namespace MusicStore.Controllers
public IActionResult Index()
{
// Get most popular albums
var albums = cache.GetOrAdd("topselling", context =>
var albums = cache.GetOrSet("topselling", context =>
{
//Refresh it every 10 minutes. Let this be the last item to be removed by cache if cache GC kicks in.
context.SetAbsoluteExpiration(TimeSpan.FromMinutes(10));