Пример #1
0
        /// <summary>
        /// Adds a pair of key and value to the cache. Throws an exception or reports error
        /// if the specified key already exists in the cache.
        /// </summary>
        /// <param name="key">key of the entry.</param>
        /// <param name="cacheEntry">the cache entry.</param>
        /// <returns>returns the result of operation.</returns>
        internal override CacheAddResult AddInternal(object key, CacheEntry cacheEntry, bool isUserOperation, OperationContext operationContext)
        {
            CacheAddResult result = base.AddInternal(key, cacheEntry, isUserOperation, operationContext);

            if (result == CacheAddResult.Success || result == CacheAddResult.SuccessNearEviction)
            {
                _grpIndexManager.AddToGroup(key, cacheEntry.GroupInfo);


                if (_queryIndexManager != null && cacheEntry.QueryInfo != null)
                {
                    _queryIndexManager.AddToIndex(key, cacheEntry, operationContext);
                }
            }

            if (_context.PerfStatsColl != null)
            {
                if (_queryIndexManager != null)
                {
                    _context.PerfStatsColl.SetQueryIndexSize(_queryIndexManager.IndexInMemorySize);
                }

                _context.PerfStatsColl.SetGroupIndexSize(_grpIndexManager.IndexInMemorySize);
            }
            return(result);
        }
Пример #2
0
        /// <summary>
        /// Método interno acionado para adicionar um novo item.
        /// </summary>
        /// <param name="key">Chave do item.</param>
        /// <param name="cacheEntry">Instancia da entrada que está sendo adicionada.</param>
        /// <param name="isUserOperation">True se for uma operação do usuário.</param>
        /// <returns>Resultado da operação.</returns>
        internal override CacheAddResult AddInternal(object key, CacheEntry cacheEntry, bool isUserOperation)
        {
            CacheAddResult result = base.AddInternal(key, cacheEntry, isUserOperation);

            switch (result)
            {
            case CacheAddResult.Success:
            case CacheAddResult.SuccessNearEviction:
                _grpIndexManager.AddToGroup(key, cacheEntry.GroupInfo);
                if ((_queryIndexManager != null) && (cacheEntry.QueryInfo != null))
                {
                    _queryIndexManager.AddToIndex(key, cacheEntry);
                }
                break;
            }
            return(result);
        }