public async Task <string> StoreAsync(ServiceTicket ticket)
        {
            var options = new DistributedCacheEntryOptions {
                AbsoluteExpiration = ticket.Assertion.ValidUntil
            };
            var value = Serialize(ticket);
            await cache.SetAsync(CombineKey(ticket.TicketId), value).ConfigureAwait(false);

            return(ticket.TicketId);
        }
        public Task <string> StoreAsync(ServiceTicket ticket)
        {
            var policy = new CacheItemPolicy();

            if (ticket.Assertion.ValidUntil != null)
            {
                policy.AbsoluteExpiration = ticket.Assertion.ValidUntil.Value.ToLocalTime();
            }
            _cache.Add(CacheKeyFactory(ticket.TicketId), ticket, policy);
            return(Task.FromResult(ticket.TicketId));
        }
        public Task RenewAsync(string key, ServiceTicket ticket)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException(nameof(key));
            }
            var value = Serialize(ticket);

            return(cache.RemoveAsync(CombineKey(key))
                   .ContinueWith(x =>
                                 cache.SetAsync(CombineKey(key), value, new DistributedCacheEntryOptions())));
        }
        public async Task RenewAsync(string key, ServiceTicket ticket)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException(nameof(key));
            }
            var value = Serialize(ticket);
            await _cache.RemoveAsync(CacheKeyFactory(key)).ConfigureAwait(false);

            await _cache.SetAsync(CacheKeyFactory(key), value, new DistributedCacheEntryOptions
            {
                AbsoluteExpiration = ticket.Assertion.ValidUntil
            }).ConfigureAwait(false);
        }
        public async Task <string> StoreAsync(ServiceTicket ticket)
        {
            var holder = new ServiceTicketHolder(ticket);
            var value  = Serialize(holder);
            await _cache.SetAsync(
                CacheKeyFactory(ticket.TicketId),
                value,
                new DistributedCacheEntryOptions
            {
                AbsoluteExpiration = ticket.Assertion.ValidUntil
            }).ConfigureAwait(false);

            return(ticket.TicketId);
        }
        public Task RenewAsync(string key, ServiceTicket ticket)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException(nameof(key));
            }
            var policy = new CacheItemPolicy();

            if (ticket.Assertion.ValidUntil != null)
            {
                policy.AbsoluteExpiration = ticket.Assertion.ValidUntil.Value.ToLocalTime();
            }
            _cache.Set(CacheKeyFactory(ticket.TicketId), ticket, policy);
            return(Task.CompletedTask);
        }