useCache takes in as it's first parameter the key that will be sent to getter and setter functions to retrieve/store data.
Further arguments will be used in order to determine how the data is stored and retrieved.
In the example bellow, myLocalCache and myRemoteCache are imaginary caches that we use to demonstrate the function.
const data = await useCache<OurReturnType>(
'myKey',
// Resolver with both getter and setter
{
get: async (key) => {
// Get the key from our local cachereturnawait myLocalCache.get(key);
},
set: async (key, value) => {
// Set the key in our local cacheawait myLocalCache.set(key, value);
},
},
// Resolver with only getterasync (key) => {
// Get the key from our remote cachereturnawait myRemoteCache.get(key);
}
);
Something with cache ig. Utilities for Caching / Data Fallback Handling
The npm package cache-fns receives a total of 1 weekly downloads. As such, cache-fns popularity was classified as not popular.
We found that cache-fns demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 1 open source maintainer collaborating on the project.
Last updated on 15 Dec 2023
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).
LDAPjs, an LDAP Client and Server API for Node.js, was decommissioned after its maintainer received an abusive email from a user, raising concerns about this form of abuse as a potential attack vector.
CISA launched a new project called Vulnrichment to enrich CVEs with details that help prioritize patching and mitigation efforts, as the NVD backlog of unenriched CVEs awaiting analysis surpasses 10,000.