Skip to content

A Node.js library that implements a simple cache around AWS DynamoDB

License

Notifications You must be signed in to change notification settings

einnjo/dynamodb-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dynamodb-cache

A simple cache with ttl support built around DynamoDB.

Usage

import { DynamoCache } from 'dynamodb-cache';

const cache = new DynamoCache<string>({
  tableName: 'my-cache-table',
  ttlAttribute: 'ttl',
  ttlSeconds: 180
});

Creating a cache with custom serialization and deserialization functions.

const cache = new DynamoCache<string>({
  tableName: 'my-cache-table',
  ttlAttribute: 'ttl',
  ttlSeconds: 180,
  // NOTE: These are the default implementations.
  serializer: (value: string) => JSON.stringify(value),
  deserializer: (value: string) => JSON.parse(value)
});

API docs

See the generated docs here.

Creating the DynamoDB table

The cache is backed by a DynamoDB table that you need to create before using the module.

The requirements are:

  • A single partition key on a column named key and type string.
  • An optional ttl specification on a column name of your choice, we suggest ttl (Remember to specify it when constructing a DynamoCache instance)

About

A Node.js library that implements a simple cache around AWS DynamoDB

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published