-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose methods to allow running cronjobs against session's expiry time #148
Comments
Yeah, I've also been thinking about this issue. Taking advantage of |
Yh amazing, I will keep a look out for that. another take I have is maybe hold an array of sessionIds that were issued in a day as the value. then I think you could open up to using both const db = await Deno.openKv();
const entries = db.list({ start: [KV_PREFIX, "01-01-2020"], end: [KV_PREFIX, "04-01-2022"] }) // array of arrays
for await (const entry of entries) {
entry.key; // [KV_PREFIX, expiry_as_unix]
entry.value; // [sessionId1, sessionId2, sessionIdN]
entry.versionstamp; // "00000000000000010000"
}
const entry = db.get([KV_PREFIX, "01-01-2020"])
entry.key; // [KV_PREFIX, expiry_as_unix]
entry.value; // [sessionId1, sessionId2, sessionIdN]
entry.versionstamp; // "00000000000000010000" |
So it seems that to strike the best balance between KV-space efficiency and user convenience, the most we can do is set OAuth session entries to expire in KV automatically and not site sessions. Keeping site sessions indefinitely allows us to use the refresh token to refresh the access token without requiring user interaction. Check out #170. I'll merge that PR once KV entry expiry is supported on Deno Deploy. |
Ah I see, that looks good to me. Also reading through the PR, was nice to learn the recommended expiry time stated by RFC6749. And I found the PR referencing the support for expiry so will keep a look for that too. Thank you |
FYI, take a look at #224. It removes all database storage and retrieval of tokens. That means this module will automatically keep the database completely clean once implemented alongside OAuth session expiry. |
Oh I have just updated my deno project using this module so good timing. I will lookout for the breaking change. ty |
I have enjoyed using this library for handling sessions. However I have noticed that at some point there will be sessions that don't get deleted from the the store and so overtime could grow and will need a way to delete them.
As I understand the Kv store API currently doesn't have and true TTL capabilities natively but I think it should be possible to still expose a way to search/filter sessions by expiry time.
The official docs state this:
Based on this I think if a key included a timestamp (could be
[PREFIX, timestamp]
) then could expose a function likegetExpiredSessions
that may look like this:I'm unsure on the
deleteExpiredSessions
method but I think it would need to use transactions for consistency.Be interested to open the dialogue to see other opinions on the matter.
I saw this bit of code and felt it may be a good starting point
The text was updated successfully, but these errors were encountered: