Skip to content

davidgtonge/cachify-mongo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cachify-mongo || memoize-to-mongo

A simple utility function that transparently caches slow async calls to Mongo.

API:

const collection = getDbCollection() // A MongoDB Collection
const cachify = require("cachify-mongo")(collection)
const myAsyncFunction = require("...") // Any function that returns a promise

const cachedFunction = cachify(myAsyncFunction)
const myCustomCachedFn = cachify(myAsyncFunction, {
  expires: 60, // seconds
  keyFn: (a) => "something:" + a.id, // a fn that returns a string - must be unique
})

This module is especially useful for caching API calls.

About

Memoize async functions with storage in Mongo - useful for caching API calls

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published