diff --git a/lib/history.js b/lib/history.js index 0744d30..59013fc 100644 --- a/lib/history.js +++ b/lib/history.js @@ -1,9 +1,23 @@ 'use strict'; +const redis = require('redis'); const CircularBuffer = require("circular-buffer"); + +const config = require('komodo-sdk/config'); +const redisClient = redis.createClient(config.redis || { host: '127.0.0.1' }); const history = new CircularBuffer(1000); +const REDIS_KEYWORD = `SHAKIR_SMS_HISTORY_${config.name||'SMS'}`; + +function fetchFromRedis() { + redisClient.LRANGE(REDIS_KEYWORD, 0, -1, (err, reply) => { + console.log(reply); + }) +} +fetchFromRedis(); + function push(item) { + redisClient.LPUSH(REDIS_KEYWORD, JSON.stringify(item)); history.push(item); }