diff --git a/README.md b/README.md index 450cad8..7ae2262 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # recommendationRaccoon (raccoon) +##Updated to handle Azure Redis server ## + An easy-to-use collaborative filtering based recommendation engine and NPM module built on top of Node.js and Redis. The engine uses the Jaccard coefficient to determine the similarity between users and k-nearest-neighbors to create recommendations. This module is useful for anyone with users, a store of products/movies/items, and the desire to give their users the ability to like/dislike and receive recommendations based on similar users. Raccoon takes care of all the recommendation and rating logic. It can be paired with any database as it does not keep track of any user/item information besides a unique ID. diff --git a/lib/algorithms.js b/lib/algorithms.js index 17b9695..948b9d2 100644 --- a/lib/algorithms.js +++ b/lib/algorithms.js @@ -2,6 +2,7 @@ const async = require('async'), config = require('./config.js'), _ = require('underscore'), + client = require('./client.js'), Key = require('./key'); // the jaccard coefficient outputs an objective measurement of the similarity between two objects. in this case, two users. the coefficient diff --git a/lib/client.js b/lib/client.js index 50de84d..07ea172 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1,14 +1,26 @@ - const redis = require('redis'), config = require('./config'), bluebird = require('bluebird'); bluebird.promisifyAll(redis.RedisClient.prototype); -client = redis.createClient(config.redisPort, config.redisUrl); -if (config.redisAuth){ - client.auth(config.redisAuth, function (err) { - if (err) { throw err; } +let client; +if (config.redisUseSsl) { + client = redis.createClient(config.redisPort, config.redisUrl, { + socket_keepalive: true, + connect_timeout: 10000, + retry_max_delay: 200, + max_attempts: 5, + auth_pass: config.redisAuth, + tls: {servername: config.redisUrl}, + }); +} else { + client = redis.createClient(config.redisPort, config.redisUrl, { + socket_keepalive: true, + connect_timeout: 10000, + retry_max_delay: 200, + max_attempts: 5, + auth_pass: config.redisAuth, }); } diff --git a/lib/config.js b/lib/config.js index cc18dd5..a62910c 100644 --- a/lib/config.js +++ b/lib/config.js @@ -8,6 +8,7 @@ class Config { this.redisUrl = process.env.RACCOON_REDIS_URL || '127.0.0.1'; this.redisPort = process.env.RACCOON_REDIS_PORT || 6379; this.redisAuth = process.env.RACCOON_REDIS_AUTH || ''; + this.redisUseSsl = process.env.RACCOON_REDIS_ENABLE_SSL || false; } } diff --git a/lib/input.js b/lib/input.js index a646af4..5e75591 100644 --- a/lib/input.js +++ b/lib/input.js @@ -2,6 +2,7 @@ const config = require('./config.js'), algo = require('./algorithms.js'), async = require('async'), + client = require('./client.js'), Key = require('./key'); const updateSequence = function(userId, itemId, options = {}){