Ejemplo n.º 1
0
        protected void ExpireEntries()
        {
            var now = _state.TimeResolver();

            // TODO: Think how to expire under memory pressure and limit the collection to avoid OOM exceptions
            ExpireIndex(now, _state._counterIndex, entry => _state.CounterDelete(entry));
            ExpireIndex(now, _state._hashIndex, entry => _state.HashDelete(entry));
            ExpireIndex(now, _state._listIndex, entry => _state.ListDelete(entry));
            ExpireIndex(now, _state._setIndex, entry => _state.SetDelete(entry));
            ExpireJobIndex(now, _state);
        }
Ejemplo n.º 2
0
        private static void CounterIncrement(InMemoryState state, string key, int value, TimeSpan?expireIn)
        {
            var counter = state.CounterGetOrAdd(key);

            counter.Value += value;

            if (counter.Value != 0)
            {
                if (expireIn.HasValue)
                {
                    state.CounterExpire(counter, expireIn);
                }
            }
            else
            {
                state.CounterDelete(counter);
            }
        }