feat (cache): impl. soft-delete of users in cache #5173
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, when all the auth tokens for a user
where deleted, we deleted the user along with all
the cached resources for that user. This can
create a lot of churn in the cache, especially if
the auth tokens have a short TTL (like 8 hrs), which
can cause all the resources to be reloaded every
morning when the user logs in.
This change introduces a soft-delete of users in
the cache. When all the auth tokens for a user are
deleted, but there's still a valid refresh token
that's less than 20 days old, we mark the user as
deleted in the cache and do not return the user in
the list of users returned by the cache, but we
still keep the user in the cache (all all their
cached resources). This way, when the user logs in
again, we can just mark the user as active again
and not have to reload all the resources. If
the refresh token is older than 20 days, we delete
the user from the cache along with all their cached
resources.