2.2.62 • Published 11 months ago

func-cache v2.2.62

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

Fun cache

This is the fun and cache.

How does it work:

It stores a map of results of a function and uses arguments as keys, for faster response,

Note that if the function result in different results with the same argument, the cache wouldn't work.

How to use:

import funcache from "func-cache";

const cachedFibonacci = funcache((num: number) => {
    // ... your function here
}, options); // about the options, see below


console.log(cachedFibonacci(1000)); //-- viewing the result

console.log(cachedFibonacci.noCache(1000)); //-- run without caching

console.log(cachedFibonacci.clearCache()); //-- to clear the cache

Options:

import funcache, { localStorageCacher, fSCacher, redisCacher, upstashCacher } from "func-cache";

const options = {
  // (1 sec) in miliseconds
  lifeTime: 1000, 

  /** debounce time wait to call onDataUpdate, default 1000ms */
  debounceTimer: 200,

  /** incase the call is async, (sometimes the script doesn't detect it's async and wont run the await for it) default: false */
  async: true,


    
  // place to store the cache, incase of restarts (browser only)
  ...localStorageCacher("_cachePlace_for_fibonacci"), 

  // place to store the cache, incase of restarts (server only). fs way
  ...fSCacher("./_cachePlace_for_fibonacci.json"), 

  // place to store the cache, incase of restarts (server only). redis way
  ...redisCacher("_cachePlace_for_fibonacci", {
    client: redisClient,
  }),

  // place to store the cache, incase of restarts (server only). upstash way
  ...upstashCacher("_cachePlace_for_fibonacci", {
    client: upstashClient,
  }),
};
2.2.62

11 months ago

2.1.2

1 year ago

2.0.3

1 year ago

2.2.0

1 year ago

2.1.1

1 year ago

2.0.2

1 year ago

2.2.3

1 year ago

2.1.25

1 year ago

2.0.5

1 year ago

2.2.2

1 year ago

2.0.4

1 year ago

2.2.5

1 year ago

2.1.23

1 year ago

2.0.7

1 year ago

2.1.24

1 year ago

2.1.21

1 year ago

2.0.75

1 year ago

2.1.22

1 year ago

2.0.76

1 year ago

2.0.73

1 year ago

2.0.74

1 year ago

2.0.71

1 year ago

2.0.72

1 year ago

2.1.0

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.3.8

1 year ago

2.2.61

1 year ago

1.3.7

1 year ago

1.3.6

1 year ago

1.3.5

1 year ago

1.3.4

1 year ago

1.3.2

1 year ago

1.3.0

2 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago