Created
April 20, 2022 01:48
-
-
Save avivl/76f6df01227351f7d17faa54d6deef43 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| var LRUCache = require('mnemonist/lru-cache'); | |
| var getJobPostCache = new LRUCache(1000); | |
| export const getJobPostJson = async (jobId: string) => { | |
| const job = getJobPostCache.get(jobId) | |
| if (job !== undefined) { | |
| return ({ | |
| job, | |
| isJobBelongsToThisUser: true | |
| }) | |
| } | |
| return _getJobPost(jobId).then((snapshot: any) => { | |
| const docs = snapshot.docs.map((doc: { data: () => any; }) => doc.data()); | |
| getJobPostCache.set(jobId, docs ) | |
| return ( | |
| { job: docs, isJobBelongsToThisUser: true } | |
| ); | |
| }).catch(error => { | |
| logger.error(error) | |
| return ({ | |
| status: "error", | |
| message: error.message, | |
| }) | |
| }) | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@odedmagger Thank you for your feedback!