marcoCasamento / Hangfire.Redis.StackExchange

HangFire Redis storage based on original (and now unsupported) Hangfire.Redis but using lovely StackExchange.Redis client
Other
456 stars 109 forks source link

Job has expired #15

Closed VoidMonk closed 8 years ago

VoidMonk commented 8 years ago

Successful jobs appear as expired within a day or so, Is there a way to extend the storage time period to keep successful jobs & related data for longer?

marcoCasamento commented 8 years ago

sure, that's totally unrelated to hangifre.redis it's something that you can configure through redis core's filters as explained here: http://discuss.hangfire.io/t/how-to-configure-the-retention-time-of-job/34/7 I use the following class

public class ProlongExpirationTimeAttribute : JobFilterAttribute, IApplyStateFilter
{
    TimeSpan _jobExpirationTimeout;

    public ProlongExpirationTimeAttribute(TimeSpan jobExpirationTimeout)
    {
        _jobExpirationTimeout = jobExpirationTimeout;
    }

    public void OnStateApplied(ApplyStateContext context, IWriteOnlyTransaction transaction)
    {
        context.JobExpirationTimeout = _jobExpirationTimeout;
    }

    public void OnStateUnapplied(ApplyStateContext context, IWriteOnlyTransaction transaction)
    {

    }
}

and then, in the startup:

GlobalJobFilters.Filters.Add(
    new ProlongExpirationTimeAttribute(mySomeHowRetrievedExpirationTimespan));

HTH

VoidMonk commented 8 years ago

Thanks!

smokinguns commented 7 years ago

when do the expired jobs disappear all together? If I have a recurring job that occurs every minute, i do not want to see the expired jobs a month from now. I do see SucceededListSize. Now I'm wondering if this limits the size in redis