Skip to main content

Momento

Prerequisites

Installation

npm i @winglibs/momento

Usage

bring cloud;
bring momento;

let token = new cloud.Secret("momento-key");
let cache = new momento.Cache(token: token);

new cloud.Function(inflight () => {
cache.set("key", "value");
log(cache.get("key"));
});

To deploy an application with Momento resources using Terraform, you will need to set the MOMENTO_API_KEY environment variable to a valid super-user API key on the machine running terraform apply.

You will also need a valid Momento token (super-user token or fine-grained access token) with permissions for performing any data operations on the cache(s) that can be used by the application. You can set the secret by running wing secrets -t tf-aws main.w. You are responsible for rotating the secret as needed.

See the Momento documentation for more information about creating API keys.

License

This library is licensed under the MIT License.

API Reference

Table of Contents

Cache (preflight class)

No description

Constructor

new(props: CacheProps): Cache

Properties

No properties

Methods

SignatureDescription
inflight get(key: str): str?No description
inflight set(key: str, value: str, opts: CacheSetOptions?): voidNo description

ICache (interface)

No description

Properties

No properties

Methods

SignatureDescription
inflight get(key: str, opts: CacheGetOptions?): str?Get a value from the cache.
inflight set(key: str, value: str, opts: CacheSetOptions?): voidSet a value in the cache.

CacheGetOptions (struct)

No description

Properties

No properties

CacheProps (struct)

No description

Properties

NameTypeDescription
defaultTtlduration?The default time-to-live for cache entries. @default 60
namestr?The name of the cache. @default - a unique id will be generated
tokenSecretA secret containing the Momento API key to use for accessing the cache at runtime.

CacheSetOptions (struct)

No description

Properties

NameTypeDescription
ttlduration?The time-to-live for the cache entry, in seconds. @default 60s