This is a beginners workshop for Node.js engineers who would like to work with Redis.
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.
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
Try to do the following before coming to the workshop. If not, that's okay too.
- Install the current LTS version: https://nodejs.org/en/
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
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
$ 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