Momento Cache is a fast, simple, pay-as-you-go caching solution without any of the operational overhead required by traditional caching solutions. This repo contains the source code for the Momento JavaScript client libraries.
To get started with Momento you will need a Momento Auth Token. You can get one from the Momento Console.
- Website: https://www.gomomento.com/
- Momento Documentation: https://docs.momentohq.com/
- Getting Started: https://docs.momentohq.com/getting-started
- JavaScript SDK Documentation: https://docs.momentohq.com/develop/sdks/nodejs
- Discuss: Momento Discord
There are two different JavaScript SDKs available for Momento on npmjs. The API is identical in both SDKs, but each is best suited for a particular environment:
@gomomento/sdk
: the Momento node.js SDK, for use in server-side applications and other node.js environments where performance considerations are key.@gomomento/sdk-web
: the Momento web SDK, for use in browsers or other non-node.js JavaScript environments. More portable but less performant for server-side use cases.
import {CacheGet, CacheClient, Configurations, CredentialProvider} from '@gomomento/sdk';
async function main() {
const cacheClient = new CacheClient({
configuration: Configurations.Laptop.v1(),
credentialProvider: CredentialProvider.fromEnvironmentVariable({
environmentVariableName: 'MOMENTO_AUTH_TOKEN',
}),
defaultTtlSeconds: 60,
});
await cacheClient.createCache('cache');
await cacheClient.set('cache', 'foo', 'FOO');
const getResponse = await cacheClient.get('cache', 'foo');
if (getResponse instanceof CacheGet.Hit) {
console.log(`Got value: ${getResponse.valueString()}`);
}
}
main().catch(e => {
throw e;
});
Documentation is available on the Momento Docs website.
Working example projects, with all required build configuration files, are available for both the node.js and web SDKs:
If you are interested in contributing to the SDK, please see the CONTRIBUTING docs.
For more info, visit our website at https://gomomento.com!