diegoaguilar
diegoaguilar

Reputation: 8376

How to properly set up a native redis connection for a Sails application?

I'd like to use redis connections for my sails application but I dont want to use sail-redis as I won't bind it to any model.

So I identify what steps I should follow.

  1. Connect Redis using any node adapter. This probably should be done at bootstrap sails process.
  2. Expose Redis globally and/or bind it to a Service.

Then I get quite confused as I don't really know how to expose any object globally and, in case I need it, prepare functions using redis and binding to any custom service.

How can I achieve it?

Upvotes: 1

Views: 580

Answers (1)

Alexis N-o
Alexis N-o

Reputation: 3993

You could attach your Redis adapter to the sails object in the bootstrap

// config/bootstrap.js
sails.redis = your_redis_adapter

The sails object being accessible globally, you will be able to access to the redis adapter from any point of your application too.

Upvotes: 1

Related Questions