@gomomento/sdk
TypeScript icon, indicating that this package has built-in type declarations

1.40.1 • Public • Published

logo

project status project stability

Momento Node.js Client Library

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 Node.js client library.

To get started with Momento you will need a Momento Auth Token. You can get one from the Momento Console.

Packages

The node.js SDK is available on npmjs: @gomomento/sdk.

The node.js SDK is the best choice for server-side JavaScript applications or environments where performance considerations are key. If you are writing a browser application or other JavaScript code that will run outside of node.js, check out the Momento Web SDK.

Usage

import {CacheGet, CacheClient, Configurations, CredentialProvider} from '@gomomento/sdk';

async function main() {
  const cacheClient = await CacheClient.create({
    configuration: Configurations.Laptop.v1(),
    credentialProvider: CredentialProvider.fromEnvironmentVariable({
      environmentVariableName: 'MOMENTO_API_KEY',
    }),
    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;
});

Getting Started and Documentation

Documentation is available on the Momento Docs website.

Examples

Working example projects, with all required build configuration files, are available in the examples subdirectory.

Developing

If you are interested in contributing to the SDK, please see the CONTRIBUTING docs.


For more info, visit our website at https://gomomento.com!

Keywords

none

Install

DownloadsWeekly Downloads

917

Version

1.40.1

License

Apache-2.0

Unpacked Size

923 kB

Total Files

101

Last publish

Collaborators

  • gomomento