Momento client-sdk-javascript
:warning: Experimental SDK :warning:
JavaScript SDK for Momento is experimental and under active development.
There could be non-backward compatible changes or removal in the future.
Please be aware that you may need to update your source code with the current version of the SDK when its version gets upgraded.
JavaScript SDK for Momento, a serverless cache that automatically scales without any of the operational overhead required by traditional caching solutions.
Getting Started :running:
Requirements
Installing Momento and Running the Example
Check out our JavaScript SDK example repo!
Using Momento
import {SimpleCacheClient, CacheGetStatus} from '@gomomento/sdk';
const authToken = process.env.MOMENTO_AUTH_TOKEN;
const DEFAULT_TTL = 60;
const momento = new SimpleCacheClient(authToken, DEFAULT_TTL);
const CACHE_NAME = 'myCache';
await momento.createCache(CACHE_NAME);
await momento.set(CACHE_NAME, 'key', 'value');
const res = await momento.get(CACHE_NAME, 'key');
console.log('result: ', res.text());
await momento.set(CACHE_NAME, 'key2', 'value2', 5);
await momento.deleteCache(CACHE_NAME);
Running Tests :zap:
Integration tests require an auth token for testing. Set the env var TEST_AUTH_TOKEN
to
provide it.
export TEST_AUTH_TOKEN=<YOUR_AUTH_TOKEN>
npm run integration