Skip to content

Instantly share code, notes, and snippets.

@avivl
Created April 20, 2022 01:48
Show Gist options
  • Select an option

  • Save avivl/76f6df01227351f7d17faa54d6deef43 to your computer and use it in GitHub Desktop.

Select an option

Save avivl/76f6df01227351f7d17faa54d6deef43 to your computer and use it in GitHub Desktop.
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,
})
})
}
@avivl
Copy link
Author

avivl commented Apr 20, 2022

@odedmagger Thank you for your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment