Momento
Prerequisites
- winglang
- Momento account and API key (see Getting started with Momento)
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
- Classes
- Interfaces
- Structs
Cache (preflight class)
No description
Constructor
new(props: CacheProps): Cache
Properties
No properties
Methods
Signature | Description |
---|---|
inflight get(key: str): str? | No description |
inflight set(key: str, value: str, opts: CacheSetOptions?): void | No description |
ICache (interface)
No description
Properties
No properties
Methods
Signature | Description |
---|---|
inflight get(key: str, opts: CacheGetOptions?): str? | Get a value from the cache. |
inflight set(key: str, value: str, opts: CacheSetOptions?): void | Set a value in the cache. |
CacheGetOptions (struct)
No description
Properties
No properties
CacheProps (struct)
No description
Properties
Name | Type | Description |
---|---|---|
defaultTtl | duration? | The default time-to-live for cache entries. @default 60 |
name | str? | The name of the cache. @default - a unique id will be generated |
token | Secret | A secret containing the Momento API key to use for accessing the cache at runtime. |
CacheSetOptions (struct)
No description
Properties
Name | Type | Description |
---|---|---|
ttl | duration? | The time-to-live for the cache entry, in seconds. @default 60s |