-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: caching implementation on user profile API (#1053)
* fix: caching implementation on user profile API * fix: cache code review comments
- Loading branch information
1 parent
a4747ed
commit 5dc0dee
Showing
5 changed files
with
494 additions
and
454 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { LRUCache } from 'lru-cache'; | ||
|
||
export const cache = new LRUCache<string, any>({ | ||
max: 200, | ||
maxSize: 500 * 1024, // 500KB | ||
sizeCalculation: (value, key) => { | ||
return typeof value === 'string' | ||
? value.length | ||
: new TextEncoder().encode(JSON.stringify(value)).length; | ||
}, | ||
ttl: 1000 * 60 * 5, // 5 minutes | ||
allowStale: false, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.