private bool CheckItemExpired(CachedItem item)
        {
            if (item.ExpireAt >= DateTime.Now)
            {
                return(false);
            }

            //does the work of TTL collections early - TTL is only "fired" once a minute or so
            MongoCollection.Remove(Query.EQ("_id", item.Key));

            return(true);
        }
        public void Add(string key, object o, DateTimeOffset expiration, string dependsOnKey = null)
        {
            if (key.Length > 256) //saves calling getByteCount if we know it could be less than 1024 bytes
            {
                if (Encoding.UTF8.GetByteCount(key) >= 1024)
                {
                    throw new KeyTooLongException();
                }
            }

            var cachedItem = new CachedItem(key, o, expiration.DateTime);

            MongoCollection.Save(cachedItem);
        }