1.0.1 • Published 6 years ago

@trussle/memory-cache v1.0.1

Weekly downloads
545
License
MIT
Repository
-
Last release
6 years ago

Memory Cache

A basic in-memory cache for JavaScript that exposes a getOrElse method written in typescript.

Why anouther in-memory cache?

Many feature rich in-memory cache implmentations exist for JavaScript but lack the following;

  • getOrElse method that populates the cache when missing
  • TypeScript definitions

Installation

npm install --save @trussle/memory-cache

Usage

import Cache from "@trussle/memory-cache";

const arnCache = new Cache<string>();

const topicArn = arnCache.getOrElse(topic, async (): Promise<string> => {
  const { TopicArn }: { TopicArn: string } = await this.sns.createTopic({
    Name: topic
  });
  return TopicArn;
});
1.0.1

6 years ago

1.0.0

6 years ago