How to connect Redis in actionHero

195 views
Skip to first unread message

sanm...@gmail.com

unread,
Jul 14, 2016, 3:37:45 AM7/14/16
to actionHero.js
I am unable to use redis function inside action hero like redis.get,redis.set,redis.incr

I ma getting redis.get is not a function

Clay Himmelberger

unread,
Jul 14, 2016, 8:57:35 AM7/14/16
to actionHero.js
inside an AH initializer, task or action, you'll have access to the `api` object. The redis connection (in v14), configured in config/redis.js, is available with api.config.redis.client. 

So to make a call to find the list length in redis, you'd make a call like 

api.config.redis.client.llen( key, function(err, length){
  api
.log('length was ' + length);
} );

Clay Himmelberger

unread,
Jul 14, 2016, 10:40:35 AM7/14/16
to actionHero.js
Actually, it is
api.redis.clients.client

Sorry for the confusion.

On Thursday, July 14, 2016 at 8:57:35 AM UTC-4, Clay Himmelberger wrote:
inside an AH initializer, task or action, you'll have access to the `api` object. The redis connection (in v14), configured in config/redis.js, is available with api.redis.clients.client. 

So to make a call to find the list length in redis, you'd make a call like 

api.redis.clients.client.llen( key, function(err, length){
  api
.log('length was ' + length);
} );
Reply all
Reply to author
Forward
0 new messages