The Redis connector enables LoopBack applications to connect to Redis data sources.

StrongLoop Labs

This project provides early access to advanced or experimental functionality. It may lack usability, completeness, documentation, and robustness, and may be outdated.

However, StrongLoop supports this project. Community users, please report bugs on GitHub.

For more information, see StrongLoop Labs.

Note:The Redis connector requires Redis 3.0.3+.

Installation

In your application root directory, enter this command to install the connector:

  1. $ npm install loopback-connector-redis --save

This will install the module and add it as a dependency to the application’s package.json file.

Creating a Redis data source

Use the data source generator to add a Redis data source to your application.When prompted for the connector, choose other, then enter redis for the connector name.The entry in the application’s server/datasources.json will look like this:

server/datasources.json

  1. "redisDS": {
  2. "name": "redisDS",
  3. "connector": "redis",
  4. }

Edit datasources.json to add other properties that enable you to connect the data source to a Redis database.

Properties

PropertyTypeDescription
connectorStringConnector name, either "loopback-connector-redis" or "redis"
databaseStringDatabase name
hostString Database host name. For connector versions <= v0.1.0, when this property is set, the port property must also be set.
passwordStringPassword to connect to database
portNumberDatabase TCP port
urlStringUse instead host and port properties.
usernameStringUsername to connect to database

Tags: connectors