Rename GetOrAdd to GetOrSet.
This commit is contained in:
parent
6d9bc21e83
commit
6f7560e33b
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Reference in New Issue