2.0.0 • Published 7 months ago

mono-cache v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

mono-cache

install to npm dependencies :

npm i -D mono-cache

usage:

import cache from 'mono-cache';

interface CacheState {
  name: string;
  age: number;

  next: {
    weight: number;
    height: number;
  };
}

const c = cache<CacheState>();
c.set('name', 'mono-cache');
c.set('age', 18);
c.set('next.weight', 60);
c.set('next.height', 180);

const name = c.get('name');
const age = c.get('age');
const next = c.get('next');
console.log(name, age, next);

// ttl

c.set('name', 'mono-cache', 1000); // 1000 = 1s

// how to get result type on get method ?

import { CachePaths } from './type';

const nextPaths: CachePaths<CacheState> = 'next';
const typedNext = c.get<typeof nextPaths>(nextPaths);
console.log(typedNext.weight, typedNext.height);
2.0.0

7 months ago

1.0.10

8 months ago

1.0.9

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago