Hangfire icon indicating copy to clipboard operation
Hangfire copied to clipboard

Feature Request: Add custom sql queries to ExpirationManager

Open luizfbicalho opened this issue 2 years ago • 0 comments

It would be nice to add custom queries to ExpirationManager, this way when an extensions is installed, it can control the correct clean of their data

For example I need to add this to clean my data.

declare @total int = 0
declare @count int = 1

while(@count>0)
begin

update 
[HangFire].[Set]  set ExpireAt = GETDATE() where [key] in (

SELECT top 10000 [key] 
FROM [HangFire].[Set] 
left join hangfire.job on job.Id = SUBSTRING([Key], 19, LEN([Key]) - 19) 

WHERE [Key] LIKE 'console:%'
and job.id is null
and [HangFire].[Set].ExpireAt is null
)

set @count = @@ROWCOUNT
set @total = @total + @count
print @total
end

Another alternative is to put the JobId in the set database and then expire the data with the end of the job

luizfbicalho avatar Apr 27 '22 19:04 luizfbicalho