HangfireIO / HangfireIO/Hangfire
Feature Request: Add custom sql queries to ExpirationManager
- Dominant language
- C#
- Stars
- 10.1k
- Forks
- 1.8k
- Avg merge
- 1h 19m
- Merged PRs (30d)
- 1
Description
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.
```SQL
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
Contributor guide
Research direction
Start by locating ExpirationManager and reviewing how Hangfire.Set and hangfire.job data are expired. Examine whether the extension scenario can be supported through an existing integration point or requires a new design, using the SQL example as the behavioral reference. Done means the supported approach for extensions to clean related data is defined and verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100