2.0.0 • Published 2 years ago

mono-cache v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years 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

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago