Skip to content

Commit 54b41a1

Browse files
committed
ready for beta
1 parent eb8a5ed commit 54b41a1

18 files changed

Lines changed: 895 additions & 55 deletions

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/*{.,-}min.js

.eslintrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"extends": "eslint:recommended",
33
"env": {
4-
// I write for browser
54
"browser": false,
6-
// in CommonJS
75
"node": true
86
},
7+
"parserOptions": {
8+
"ecmaVersion": 6
9+
},
910
"globals": {
1011
"describe": false,
1112
"before": false,

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ jspm_packages
3535

3636
# Optional REPL history
3737
.node_repl_history
38+
39+
coverage

.travis.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
language: node_js
22
node_js:
3-
- "6"
3+
- '4'
4+
- '5'
5+
- '6'
6+
- 'node'
7+
before_install:
8+
- sudo apt-key adv --keyserver pgp.mit.edu --recv D101F7899D41F3C3
9+
- echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
10+
- sudo apt-get update -qq
11+
- sudo apt-get install -y -qq yarn
12+
install: yarn
413
services:
514
- redis-server
15+
after_success:
16+
- npm run lint
17+
- npm run coveralls

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Change Log

CONTRIBUTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Contributing
2+
3+
1. Fork it
4+
2. Create your feature branch (`git checkout -b my-new-feature`)
5+
3. Commit your changes (`git commit -am 'Add some feature'`)
6+
4. Push to the branch (`git push origin my-new-feature`)
7+
5. Create new Pull Request

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
[![Build Status](https://travis-ci.org/pasupulaphani/angular-gist-embed.svg?branch=master)](https://travis-ci.org/pasupulaphani/simple-redis-cache) [![npm version](https://badge.fury.io/js/simple-redis-cache.svg)](https://badge.fury.io/js/simple-redis-cache) [![Test Coverage](https://codeclimate.com/github/pasupulaphani/simple-redis-cache/badges/coverage.svg)](https://codeclimate.com/github/pasupulaphani/simple-redis-cache/coverage) [![Code Climate](https://codeclimate.com/github/pasupulaphani/simple-redis-cache/badges/gpa.svg)](https://codeclimate.com/github/pasupulaphani/simple-redis-cache)
1+
[![npm version](http://img.shields.io/npm/v/simple-redis-cache.svg)](https://npmjs.org/package/simple-redis-cache)
2+
[![Build Status](https://travis-ci.org/pasupulaphani/simple-redis-cache.svg?branch=master)](https://travis-ci.org/pasupulaphani/simple-redis-cache)
3+
[![Coverage Status](https://coveralls.io/repos/github/pasupulaphani/simple-redis-cache/badge.svg?branch=master)](https://coveralls.io/github/pasupulaphani/simple-redis-cache?branch=master)
4+
[![dependencies Status](https://david-dm.org/pasupulaphani/simple-redis-cache/status.svg)](https://david-dm.org/pasupulaphani/simple-redis-cache)
5+
[![Gratipay donate button](https://img.shields.io/badge/gratipay-donate-yellow.svg)](https://gratipay.com/simple-redis-cache/)
26

37
# simple-redis-cache
48
Redis cache ready to scale with node-pool support
59

6-
> Note: This lib is still in alpha
10+
> Note: This lib is in beta
11+
12+
## Prerequisites
13+
14+
This module requires nodejs v4 or above as it has dependencies on constious es6 components such as Map, Set, Promise etc.
715

816
### Getting started
917

@@ -14,3 +22,7 @@ Redis cache ready to scale with node-pool support
1422

1523
// set
1624
cache.set("key", "value");
25+
26+
### Run tests
27+
28+
bash test.sh

lib/logger.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = console;

lib/redis.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const redis = require("redis");
2+
const Bluebird = require("bluebird");
3+
4+
Bluebird.promisifyAll(redis.RedisClient.prototype);
5+
Bluebird.promisifyAll(redis.Multi.prototype);
6+
7+
module.exports = redis;

lib/redis_cache.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
var Bluebird = require("bluebird");
2-
var RedisStore = require("simple-redis-store");
3-
var Debug = require("debug");
1+
var RedisStore = require("./redis_store");
2+
var logger = require("./logger");
43

5-
var debug = new Debug("simpleRedisCache");
4+
const debug = require("debug")("simpleRedisCache");
5+
6+
function RedisCache (name, logger, redisOptions, poolOptions) {
7+
let store;
68

7-
module.exports = function (name, logger, redisOptions, poolOptions) {
89
try {
910

10-
var store = new RedisStore(name, redisOptions, poolOptions);
11+
store = new RedisStore(name, redisOptions, poolOptions);
1112

1213
// setTimeout(function storeStats (store) {
1314
// // periodically report statistics
1415
//
15-
// var status = store.status();
16+
// const status = store.status();
1617
// logger.info("REDIS CACHE STORE STATS: ", status);
1718
//
1819
// if (status.waitingClients > 0) {
@@ -38,7 +39,7 @@ module.exports = function (name, logger, redisOptions, poolOptions) {
3839
.then(function (value) {
3940
if (!value) {
4041
debug("MISS", {key: key});
41-
return Bluebird.resolve(promise)
42+
return Promise.resolve(promise)
4243
.then(function (value) {
4344
value = JSON.stringify(value);
4445
store.setex(key, value, ttlInSeconds);
@@ -75,4 +76,6 @@ module.exports = function (name, logger, redisOptions, poolOptions) {
7576
return store.deleteAll();
7677
}
7778
};
78-
};
79+
}
80+
81+
module.exports = RedisCache;

0 commit comments

Comments
 (0)