Reputation: 25233
I am unsure about where would be the best place to define the redis client in a Express application I am building. I am using skeleton as the framework.
It seems like the connection to redis should go in either boot.coffee
or app.coffee
, but then I can't easily get a reference to it in application_controller.coffee
, which is where I need it.
If I put client = redis.createClient
in application_controller.coffee
, will that mean a new client is created on each request?
Upvotes: 1
Views: 160
Reputation: 3620
I would define the Redis client in app.coffee
(after configuration, before the routes) and set the Redis client as a property on the App object:
app.client = redis.createClient
Then in application_controller.coffee
you can access the Redis client by app.client
.
Upvotes: 1