Skip to content

Instantly share code, notes, and snippets.

@suhailgupta03
Created December 4, 2023 15:56
Show Gist options
  • Save suhailgupta03/82b4984ed613dfdaf32abc117cb67ad6 to your computer and use it in GitHub Desktop.
Save suhailgupta03/82b4984ed613dfdaf32abc117cb67ad6 to your computer and use it in GitHub Desktop.
let cache = {}; // just a simple js object
// cache is just some space in RAM (memory)
function getStudentDetailsFromDatabase() { // AWS - US east
return {
name: 'John',
} // response time is n seconds
}
function main() {
if(cache["result"]) {
return cache["result"];
}else {
cache["result"] = getStudentDetailsFromDatabase();
return cache["result"];
}
}
for(let i =0; i < 10000000; i++) {
main();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment