Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable travisci and add build badges #7

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
language: node_js
os:
- linux
- osx
node_js:
- '6'
- '7'
- '8'
cache:
directories:
- $HOME/.npm
before_install:
- echo node --version
- echo npm --version
- echo $TRAVIS_BRANCH
- echo `git describe --tags --always HEAD`
- npm config set progress false
- npm config set spin false
script:
- npm test
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# Advanced cache based on ioredis, redlock and node-cache
# Advanced cache based on ioredis, redlock and node-cache

[![npm](https://img.shields.io/npm/v/advanced-cache.svg?style=flat-square)](https://npm.im/advanced-cache)
[![Travis](https://img.shields.io/travis/tuananh/advanced-cache.svg?label=Linux%20%26%20macOS&style=flat-square)](https://travis-ci.org/tuananh/advanced-cache)

Main points to have this module are:
* reduce load on data storage on cold start
* unify repetitive actions as: get from cache if not load from db
* reload cache before it expires

Note: caches value only if result of load function is converted to true: `!!result === true`

# How to use RedisCache
```js
const advancedCache = require('advanced-cache')

const RedisCache = advancedCache.RedisCache
const CachePolicy = advancedCache.CachePolicy

const ioRedisOpts = {
port: 6379,
host: '127.0.0.1',
Expand All @@ -24,7 +27,7 @@ Note: caches value only if result of load function is converted to true: `!!resu
const redlockOpts = {
retryCount: 0 //default
}

const opts = {
lockIntervalMs: 1000, //time in ms key is locked to load data from store (default)
retryIntervalMs: 50 //time failed lock waits before next try (default)
Expand Down Expand Up @@ -56,7 +59,7 @@ Note: caches value only if result of load function is converted to true: `!!resu

const opts = {useClones: false} //default opts
const cache = new MemoryCache(opts)

const countryCachePolicy = new CachePolicy(['country-code', 5], 24 * 60 * 60)
cache.fetch(countryCachePolicy, loadPromise).then(countryCode => {})
```
Expand Down