Redis

From 太極
Revision as of 10:14, 4 November 2019 by Brb (talk | contribs) (→‎Tutorial)
Jump to navigation Jump to search

Web sites

Install

apt-get install redis-server # this include redis-cli

Tutorial

set vs list

https://redis.io/topics/data-types

A set is similar to a list, except it does not have a specific order and each element may only appear once.

Get a help of a command

https://redis.io/topics/rediscli

help XXX

Examples

metacran

https://github.com/metacran/metacranweb

Docker

Exploring Redis with Docker

Start a new container running Redis

docker run -d -p 6379:6379 --name redis1 redis
# Run the Redis CLI in the container
docker exec -it redis1 sh
# redis-cli
127.0.0.1:6379> set name mark
OK
127.0.0.1:6379> get name
"mark"
127.0.0.1:6379> incr counter
(integer) 1
127.0.0.1:6379> incr counter
(integer) 2
127.0.0.1:6379> get counter
"2"
127.0.0.1:6379> exit
# exit

Connect from another linked container

docker run -it --rm --link redis1:redis --name client1 redis sh
# redis-cli -h redis
redis:6379>
redis:6379> get name
"mark"
redis:6379> get counter
"2"
redis:6379> exit
# exit

Clean up

docker stop redis1
docker rm redis1