public void AddOrUpdate(TokenCacheItem item)
        {
            var session = _docStore.OpenSession();
            var dbItem = session.Load<TokenCacheItem>(item.Key);

            if (dbItem == null)
            {
                dbItem = new TokenCacheItem {Key = item.Key};
                session.Store(dbItem, item.Key);
            }
            dbItem.Token = item.Token;
            dbItem.Expires = item.Expires;
            session.SaveChanges();
        }
        public override bool TryAddEntry(object key, System.IdentityModel.Tokens.SecurityToken value)
        {
            if (key == null) throw new ArgumentNullException("key");

            var cacheKey = GetCacheKey(key);
            var item = new TokenCacheItem
            {
                Key = cacheKey,
                Expires = value.ValidTo,
                Token = TokenToBytes((SessionSecurityToken)value),
            };
            tokenCacheRepository.AddOrUpdate(item);

            return inner.TryAddEntry(key, value);
        }
 public void AddOrUpdate(TokenCacheItem item)
 {
     using (EFTokenCacheDataContext db = new EFTokenCacheDataContext())
     {
         DbSet<TokenCacheItem> items = db.Set<TokenCacheItem>();
         var dbItem = items.Find(item.Key);
         if (dbItem == null)
         {
             dbItem = new TokenCacheItem();
             dbItem.Key = item.Key;
             items.Add(dbItem);
         }
         dbItem.Token = item.Token;
         dbItem.Expires = item.Expires;
         db.SaveChanges();
     }
 }
        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);
        }