Example #1
0
        public Task <string> StoreAsync(AuthenticationTicket ticket)
        {
            Guard.Against <ArgumentNullException>(ticket.IsNull(), "StoreAsync - ticket can't be null");

            var key  = Guid.NewGuid().ToString("N");
            var json = this.serializer.Serialize(ticket);

            this.Redis.StringSet(key, json, ticket.Properties.ExpiresUtcToTimeSpanOrDefault(DefaultKeyExpiration));
            return(Task.FromResult(key));
        }
        public Task <string> StoreAsync(AuthenticationTicket ticket)
        {
            Guard.Against <ArgumentNullException>(ticket.IsNull(), "StoreAsync - ticket can't be null");

            var key  = Guid.NewGuid().ToString("N");
            var json = this.serializer.Serialize(ticket);

            this.store.TryAdd(key, json);
            return(Task.FromResult(key));
        }
Example #3
0
        public Task RenewAsync(string key, AuthenticationTicket ticket)
        {
            Guard.Against <ArgumentNullException>(key.IsNull(), "RenewAsync - key can't be null");
            Guard.Against <ArgumentNullException>(ticket.IsNull(), "RenewAsync - ticket can't be null");

            var json = this.serializer.Serialize(ticket);

            this.Redis.StringSet(key, json, ticket.Properties.ExpiresUtcToTimeSpanOrDefault(DefaultKeyExpiration));
            return(Task.FromResult(0));
        }
        public Task RenewAsync(string key, AuthenticationTicket ticket)
        {
            Guard.Against <ArgumentNullException>(key.IsNull(), "RenewAsync - key can't be null");
            Guard.Against <ArgumentNullException>(ticket.IsNull(), "RenewAsync - ticket can't be null");

            var entry = this.store.FirstOrDefault(ent => ent.Key == key);

            if (entry.IsNotNull())
            {
                var oldValue = entry.Value;
                var json     = this.serializer.Serialize(ticket);
                this.store.TryUpdate(key, json, oldValue);
            }

            return(Task.FromResult(0));
        }