Created
June 1, 2016 05:15
-
-
Save janneh/c5f7fcb4a05552ebaa3074d479285cf0 to your computer and use it in GitHub Desktop.
Simple cache
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
const cache = new Map() | |
service.get = uri => { | |
if (!cache.has(uri)) { | |
cache.set(uri, fetch(uri)) | |
} | |
return cache.get(uri) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment