This will be the first in a multi-part write up of how I use redis. I will focus on a few key areas:
- Configuring redis server
- General design for storing and retrieving data
- Language specific stuff using C# / StackExchange.Redis.
To get start you’ll need to download and install redis in some form or fashion.
- You can go to the site and download it directly: https://redis.io/download
- Or you can download the source and build it: https://github.com/antirez/redis
- Or, my preferred way, is to install Docker, and run redis from there: https://hub.docker.com/_/redis
I’m not going to walk you through installing docker in this guide, but its pretty easy.
We’ll get started by opening up your favorite command prompt and running:
docker run -it -p 6379:6379 redis:latest
This will download the image, run it interactively, and map the default port to the container.
Thats it! Now you have an instance of redis running that you can play with.
Now there are several ways for you to connect to, and play with, redis once you have it running:
- A number of gui applications (learn these later if you really want to get good)
- Install redis-cli locally
- Run redis-cli from a docker container
Again we’re going to use docker, its just the easiest way to get things going quickly. So again from your favorite command prompt type
docker run -it redis:latest redis-cli -h 192.168.10.13
You’ll want to enter the ip address of the docker host where redis was started.
I’m greeted by the following:
Now that it is up and running, and we have a client connected, we can easily save our first entry:
192.168.10.131:6379> set Hello World
192.168.10.131:6379> get Hello
That was pretty simple!
In the next article we’ll cover different productions setups, and dive into getting things setup for production.
2 thoughts on “Redis Part I”
[…] Part I we covered some very basic steps to start up a Redis server and connect to it with the redis-cli […]
[…] Part I was an introduction to some basic knowledge needed to run Redis in production. […]