Skip to content

Latest commit

 

History

History
82 lines (53 loc) · 2.49 KB

README.md

File metadata and controls

82 lines (53 loc) · 2.49 KB

Node.js + Redis Workshop

This is a beginners workshop for Node.js engineers who would like to work with Redis.

Approach

In this workshop we'll get to know some of the data structures provided by Redis. We'll first use the Redis CLI tool (redis-cli, a REPL) to issue commands and see their responses. Then, we'll go ahead and write Node.js code to make use of the same data structures.

Either check out this repository, or download a zip file of the repository. Inside you will find two directories. The first, code/, is where we'll write our application code. The second, lessons/, is where we'll be teaching from.

Takeaways

Once the workshop is done, you'll understand a few things about Redis:

  • The basic data types
  • How to use Redis from a Node.js application
  • When to use Redis vs other technologies

Pre-Requisites

Try to do the following before coming to the workshop. If not, that's okay too.

Install Node.js

Install Redis

macOS with Homebrew

If you have Homebrew installed, then follow along with these instructions. If you don't already have Homebrew installed it's worth giving it a try, as it's very beneficial to installing other software on your Mac.

$ brew install redis # this installs Redis
$ redis-server # this starts the server

# switch to a new terminal window

$ redis-cli PING # this sends a command to redis
> PONG # if you get this message back then it worked

$ redis-cli # use this for an interactive Redis REPL

Linux with Apt

If you're using Ubuntu / Debian / Linux Mint, then this is for you. We can download the Redis source code and install it.

$ sudo apt-get update
$ sudo apt-get install build-essential
$ curl -O http://download.redis.io/redis-stable.tar.gz
$ tar xzvf redis-stable.tar.gz
$ cd redis-stable
$ make
$ sudo make install
$ redis-server # this starts the server

# switch to a new terminal window

$ redis-cli PING # this sends a command to redis
> PONG # if you get this message back then it worked

$ redis-cli # use this for an interactive Redis REPL

Any OS with Docker

$ docker run \
  --name nodeschool-redis \
  -p 6379:6379 \
  -d redis \
  redis-server

# switch to a new terminal window

$ docker exec -it nodeschool-redis redis-cli PING # this sends a command to redis
> PONG # if you get this message back then it worked

$ docker exec -it nodeschool-redis redis-cli PING # use this for an interactive Redis REPL