@trussle/memory-cache
v1.0.1
Published
in-memory cache with getOrElse
Downloads
153
Maintainers
Keywords
Readme
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;
});