Optimize TokenCleanupService with a more efficient delete strategy when IOperationalStoreNotification is not in use
#510
aomader
started this conversation in
Feature requests
Replies: 1 comment 1 reply
-
|
Thanks for this suggestion! I'll forward this to our engineering team, perhaps we can still fit this one in our next release. That said, our friends at Rock Solid Knowledge have published a blog post which demonstrates how you could setup a scheduled SQL job using a stored procedure to clean up the persisted grant database table. Perhaps this is an easier solution in the short run. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, the
TokenCleanupServiceuses a two-step process for cleaning up expired grants, consumed tokens, and device codes. It first fetches a batch of records into memory and then issues a separateExecuteDeleteAsynccall to remove them from the database.As seen in
RemoveExpiredPersistedGrantsAsyncandRemoveConsumedPersistedGrantsAsync, the full entities are loaded primarily to support theIOperationalStoreNotificationfeature, which requires the collection of removed items.However, when no
IOperationalStoreNotificationis registered, fetching the entire entities into memory is unnecessary overhead. The cleanup could be performed much more efficiently with a single, directExecuteDeleteAsynccall, similar to the approach already used inRemovePushedAuthorizationRequestsAsync.Beta Was this translation helpful? Give feedback.
All reactions