Exemplo n.º 1
0
        /// <summary>
        /// Finds all the items in the retirement queue ready for removal and removes them
        /// </summary>
        public void Remove(DateTime earlierThan)
        {
            // Do it the simple scan query way
            try
            {
                var filter = new SegmentRetirementQueueQueryFilter(earlierThan.Ticks);
                var query  = new ScanQuery <ISegmentRetirementQueueKey, SegmentRetirementQueueItem>
                {
                    Filter = filter,
                    Local  = true
                };

                var toRemove = _queueCache.Query(query).GetAll().Select(x => x.Key).ToList();

                _log.LogInformation($"Removing {toRemove.Count} retirement groups from retirement queue cache");

                _queueCache.RemoveAll(toRemove);

                _log.LogInformation($"Removed {toRemove.Count} retirement groups from retirement queue cache");
            }
            catch (Exception e)
            {
                _log.LogError(e, $"{nameof(Remove)} experienced exception while removing retirees from retirement queue:");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Finds all the items in the retirement queue ready for removal and returns them
        /// </summary>
        public List <SegmentRetirementQueueItem> Query(DateTime earlierThan)
        {
            // Do it the simple scan query way
            try
            {
                var filter = new SegmentRetirementQueueQueryFilter(earlierThan.Ticks);
                var query  = new ScanQuery <ISegmentRetirementQueueKey, SegmentRetirementQueueItem>
                {
                    Filter = filter,
                    Local  = true
                };
                return(_queueCache.Query(query).GetAll().Select(x => x.Value).ToList());
            }
            catch (Exception e)
            {
                _log.LogError(e, $"{nameof(Query)} experienced exception while querying retirees:");
                return(null);
            }

            /*  var sql = new SqlQuery(typeof(SegmentRetirementQueueItem), $"_KEY.InsertUTCAsLong < {earlierThan.Ticks}")
             * {
             *  Local = true
             * };
             *
             * Log.LogInformation($"Retirement queue SQL string is {sql.Sql}");
             * Log.LogInformation($"Retirement queue SQL string is {sql}");
             *
             * try
             * {
             *  return QueueCache.Query(sql).Select(x => x.Value).ToList();
             * }
             * catch (Exception e)
             * {
             *  Log.LogError(e, $"{nameof(Query)} experienced exception while querying retirees:");
             *  return null;
             * }
             */
        }