Reacting to Caching api review changes

This commit is contained in:
Kiran Challa 2015-05-18 12:08:30 -07:00
parent af2c524352
commit 76bd1a2f17
1 changed files with 8 additions and 9 deletions

View File

@ -26,17 +26,16 @@ namespace CookieSessionSample
public Task RenewAsync(string key, AuthenticationTicket ticket)
{
_cache.Set(key, ticket, context =>
var options = new MemoryCacheEntryOptions();
var expiresUtc = ticket.Properties.ExpiresUtc;
if (expiresUtc.HasValue)
{
var expiresUtc = ticket.Properties.ExpiresUtc;
if (expiresUtc.HasValue)
{
context.SetAbsoluteExpiration(expiresUtc.Value);
}
context.SetSlidingExpiration(TimeSpan.FromHours(1)); // TODO: configurable.
options.SetAbsoluteExpiration(expiresUtc.Value);
}
options.SetSlidingExpiration(TimeSpan.FromHours(1)); // TODO: configurable.
_cache.Set(key, ticket, options);
return (AuthenticationTicket)context.State;
});
return Task.FromResult(0);
}