Пример #1
0
        /// <summary>
        ///     Only used in cache-only mode (no persistence). Eviction is activated by collection.
        ///     Two types of eviction are supported for now: LRU (Less Recently Used) or TTL (Time To Live)
        ///     In LRU mode the
        ///     <param name="limit"></param>
        ///     and
        ///     <param name="itemsToRemove"></param>
        ///     are used
        ///     In TTL mode only
        ///     <param name="timeLimitInMilliseconds"></param>
        ///     is used
        ///     When the <paramref name="limit" /> is reached the less recently used  <paramref name="itemsToRemove" /> items are
        ///     evicted
        /// </summary>
        /// <param name="evictionType">LRU or TTL</param>
        /// <param name="limit">threshold that triggers the eviction in LRU mode</param>
        /// <param name="itemsToRemove">number of items to be evicted when the threshold is reached in LRU mode</param>
        /// <param name="timeLimitInMilliseconds">items older than the specified value are evicted in TTL mode</param>
        public void ConfigEviction(EvictionType evictionType, int limit, int itemsToRemove = 100,
                                   int timeLimitInMilliseconds = 0)
        {
            if (evictionType == EvictionType.LessRecentlyUsed && limit == 0)
            {
                throw new ArgumentException("If LRU eviction is used, a positive limit must be specified");
            }

            _client.ConfigEviction(_collectionName, evictionType, limit, itemsToRemove, timeLimitInMilliseconds);
        }