-
Notifications
You must be signed in to change notification settings - Fork 387
Add optional deleteSessions, findSessionsByShop #418
Add optional deleteSessions, findSessionsByShop #418
Conversation
22cc0cf
to
38b960c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM.
One question: What is the use-case for findSessionsByShop
? Do we need to worry about the returned array being uber large for popular apps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, I had some thoughts on how to make a couple of these more efficient, but overall I think this makes sense!
): Promise<SessionInterface[] | {[key: string]: unknown}[] | undefined> { | ||
await this.ready; | ||
|
||
const keys = await this.client.keys('*'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's worth storing the ids for specific shops under a single key, so that we don't have to iterate over every entry to find the ids for a shop. Quite a big change, but I think it's worth it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
K, that would be better (anything would be better than this current search implementation!) but since it's such a big change to the underlying data structure, I'll leave it for its own PR.
It's "give me the sessions for this one shop", so, with the additional change of using offline sessions, it realistically should be just one entry. |
API library component of https://github.com/Shopify/first-party-library-planning/issues/384 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from a nit about returning the map
s directly, LGTM! Haven't tried the mongodb changes myself, though.
To support using the session database as a means to track app installations, adding optional methods to search for sessions by shop and deleting all sessions by a range of ids (e.g., for a shop, or as a garbage collector, if desired).
665c113
to
303a556
Compare
WHY are these changes introduced?
To support using the session database as a means to track app installations, adding optional methods to search for sessions by shop and deleting all sessions by a range of ids (e.g., for a shop, or as a garbage collector, if desired).
WHAT is this pull request doing?
Adding optional
findSessionsByShop
anddeleteSessions
interface methods toSessionStorage
and the corresponding implementations in the various DB adapters.Type of change
Checklist