npm

@trussle/memory-cache
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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;
});

Readme

Keywords

none

Package Sidebar

Install

npm i @trussle/memory-cache

Weekly Downloads

69

Version

1.0.1

License

MIT

Last publish

Collaborators

  • tim-tan-better
  • alexmil.reyes
  • serge.besliu
  • trussle-admin
  • mariusztrussle
  • jonny-trussle
  • nickdre
  • jucallej