public void Execute(DocumentDatabase database)
        {
            var deleteFrequencyInSeconds = RavenBootstrapper.Settings.ExpirationProcessTimerInSeconds;

            if (deleteFrequencyInSeconds == 0)
            {
                return;
            }
            var deletionBatchSize = RavenBootstrapper.Settings.ExpirationProcessBatchSize;

            logger.Info("Running deletion of expired documents every {0} seconds", deleteFrequencyInSeconds);
            logger.Info("Deletion batch size set to {0}", deletionBatchSize);
            logger.Info("Retention period for audits and sagahistory is {0}", RavenBootstrapper.Settings.AuditRetentionPeriod);
            logger.Info("Retention period for errors is {0}", RavenBootstrapper.Settings.ErrorRetentionPeriod);

            var due = TimeSpan.FromSeconds(deleteFrequencyInSeconds);

            timer = new Timer(executor =>
            {
                ExpiredDocumentsCleaner.RunCleanup(deletionBatchSize, database, RavenBootstrapper.Settings);

                try
                {
                    timer.Change(due, Timeout.InfiniteTimeSpan);
                }
                catch (ObjectDisposedException)
                {
                    //Ignored, we are shuting down
                }
            }, null, due, Timeout.InfiniteTimeSpan);
        }
        public void Execute(DocumentDatabase database)
        {
            var deleteFrequencyInSeconds = RavenBootstrapper.Settings.ExpirationProcessTimerInSeconds;

            if (deleteFrequencyInSeconds == 0)
            {
                return;
            }

            var due = TimeSpan.FromSeconds(deleteFrequencyInSeconds);
            var deletionBatchSize = RavenBootstrapper.Settings.ExpirationProcessBatchSize;

            logger.Info("Running deletion of expired documents every {0} seconds", deleteFrequencyInSeconds);
            logger.Info("Deletion batch size set to {0}", deletionBatchSize);
            logger.Info("Retention period for errors is {0}", RavenBootstrapper.Settings.ErrorRetentionPeriod);

            var auditRetention = RavenBootstrapper.Settings.AuditRetentionPeriod;

            if (auditRetention.HasValue)
            {
                logger.Info("Retention period for audits and saga history is {0}", RavenBootstrapper.Settings.AuditRetentionPeriod);
            }

            timer = new AsyncTimer(
                token => ExpiredDocumentsCleaner.RunCleanup(deletionBatchSize, database, RavenBootstrapper.Settings, token), due, due, e => { logger.ErrorException("Error when trying to find expired documents", e); });
        }