From the course: Databases for Node.js Developers

Unlock this course with a free trial

Join today to access over 24,400 courses taught by industry experts.

Connecting our application to Redis

Connecting our application to Redis - Node.js Tutorial

From the course: Databases for Node.js Developers

Connecting our application to Redis

- [Instructor] In this video, we will set up Redis in our Fastify application using the ioredis library. Let's get started. So first, I will install the library. So this is the underlying driver now. We are not installing some higher-level abstraction layer here. So it's pure Redis, npm install ioredis. So there's no object or data mapping going on here. So next, I start the application again and we start out, and you know this already with providing the configuration, and in config, I simply now add a new entry called redis. And in there I only have to provide the host, which is localhost and the port, which is 6379. So that's it for the config. Again, when you look into server.js, you will see that somewhere down there, yeah, we are bringing in redis and config.redis. So next, we are heading to the plugin section and there in databases, you'll find also an entry for redis. There you already have this scaffold for Redis and what we have to do now is actually make the connection. So…

Contents