0.11.0-alpha • Published 2 years ago

cache-eight v0.11.0-alpha

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

cache-eight

cache + v8

  • checksum keys

  • access data from json files (cache)

  • optimize functions execution time for expensive operations

  • data is saved using v8's serialize / deserialize

why?

caching expensive pure functions results

same inputs -> same results

const values = [1, 2, 3];

const key = values.toString();
const cached = deserialize(key);

// if has cached value, return early (skipping further functions)
if (cached) return cached;

//else get it from somewhere
const result = values.map(value => value * 2);

//cache the result
await serialize(key, result);

return result;
import Cache from 'cache-eight';

const cache = new Cache();

//