rethinkdb-cache
RDB warm cache module based upon https://gist.github.com/threepointone/62dd587d42819fc72284
How to use?
- Run tests:
npm install && npm test
- Install it:
npm install --save rethinkdb-cache
NOTE: You can use yarn instead of npm if you like.
- Require it:
const rdbCache = rdbSettings = host: 'localhost' port: '28015' user: 'user' password: 'password' db: 'db' timeout: 60 tableName = 'app_cache' ttl = 24; /** * @params {object || arr} rdbSettings (optional) * @params * @params * */ const CACHE = rdbSettings tableName ttl;
-
rdbSettings: An object with your usual RethinkDB connection settings, if the DB does not exist, it will be created
-
tableName: A string with the name of the table you want to use as cache table, if it does not exist, it will be created
-
ttl: An integer representing the maximum time (in hours) objects should be stored in cache before being completely flushed in order to be fully recreated instead of warmly updated
-
Usage:
const data = "name": "foobar" if !CACHE // Not-in-cache-logic goes here... CACHE; else // Return from cache const myData = JSONval; return myData;