public override SessionSecurityToken Get(SessionSecurityTokenCacheKey key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            var token = inner.Get(key);

            if (token != null)
            {
                return(token);
            }

            var item = tokenCacheRepository.Get(key.ToString());

            if (item == null)
            {
                return(null);
            }

            token = BytesToToken(item.Token);

            // update in-mem cache from database
            inner.AddOrUpdate(key, token, item.Expires);

            return(token);
        }
 public override void Remove(SessionSecurityTokenCacheKey key)
 {
     if (key == null)
     {
         throw new ArgumentNullException("key");
     }
     inner.Remove(key);
     tokenCacheRepository.Remove(key.ToString());
 }
        public override void AddOrUpdate(SessionSecurityTokenCacheKey key, SessionSecurityToken value, DateTime expiryTime)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            inner.AddOrUpdate(key, value, expiryTime);
            var item = new TokenCacheItem
            {
                Key     = key.ToString(),
                Expires = expiryTime,
                Token   = TokenToBytes(value),
            };

            tokenCacheRepository.AddOrUpdate(item);
        }