mirror of
https://github.com/guyzyl/whatsapp-contact-sync.git
synced 2026-04-25 14:05:48 +03:00
[PR #27] [MERGED] Replace client session object maps with lru-cache #92
Labels
No labels
big-feature
bug
dependencies
duplicate
enhancement
good first issue
help wanted
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/whatsapp-contact-sync#92
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/guyzyl/whatsapp-contact-sync/pull/27
Author: @guyzyl
Created: 12/9/2022
Status: ✅ Merged
Merged: 12/9/2022
Merged by: @guyzyl
Base:
main← Head:introduce-better-serverside-caching📝 Commits (1)
e330d82Replace client session object maps with lru-cache📊 Changes
6 files changed (+169 additions, -163 deletions)
View changed files
📝
server/package-lock.json(+116 -93)📝
server/package.json(+10 -9)📝
server/routes/api.ts(+15 -54)➕
server/src/cache.ts(+18 -0)📝
server/src/sync.ts(+6 -6)📝
server/src/whatsapp.ts(+4 -1)📄 Description
In the previous implementation, a WS is created for every client. The WS is saved in a session id to WS map, and from there is passed to the functions that require it when called.
This PR fixes a bug where in some cases the WS is recreated (for some reasons), causing the WS that was passed to the functions to be outdated and for the service to function as intended (for example, not redirecting after a successful WhatsApp authentication).
To fix this issue, better session caching is introduced by using the
lru-cachepackage.Now, instead of saving all of the session objects to separate maps, a central cache is used.
This fixes some bugs, makes the code cleaner, and removes a lot of code (which is always great).
This PR should fix #22 .
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.