Redis.io: Difference between revisions

From air
Jump to navigation Jump to search
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 16: Line 16:
Start redis-cli
Start redis-cli
<pre>
<pre>
docker run -it --link my-redis:redis --rm redis redis-cli -h redis -p 6379
docker run --name my-redis-cli-1 -it --link my-redis:redis --rm redis redis-cli -h redis -p 6379
</pre>
</pre>


Run commands
==Running basic commands==
<pre>
<pre>
help
help
Line 40: Line 40:


...
...
</pre>

==Transaction==
<pre>
SET counter 1
MULTI
INCR counter
DISCARD
GET counter
MULTI
INCR counter
INCR counter
EXEC
GET counter
</pre>

==Publish-Subscribe==

<pre>
HELP SUBSCRIBE
SUBSCRIBE whispers chatter
</pre>

Start a second redis-cli
<pre>
docker run --name my-redis-cli-2 -it --link my-redis:redis --rm redis redis-cli -h redis -p 6379
</pre>


<pre>
HELP PUBLISH
PUBLISH whispers "hello world"
PUBLISH chatter "hi"
</pre>

==At the end==
Clean all with
<pre>
docker rm -f my-redis-cli-2
docker rm -f my-redis-cli-1
docker rm -f my-redis
docker ps -a
</pre>
</pre>

Latest revision as of 12:24, 21 August 2017

http://redis.io/

Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

Getting started with Redis

|refcard Getting started with Redis

Redis Docker Container

Read https://hub.docker.com/_/redis/

docker run --name my-redis -d redis


Start redis-cli

docker run --name my-redis-cli-1 -it --link my-redis:redis --rm redis redis-cli -h redis -p 6379

Running basic commands

help
SET name Alice
GET name
GETSET name Bob
GET name

MSET fruit apple cookie choc-chip
MGET cookie fruit

GET counter
INCR counter
GET counter
INCRBY counter 3
GET counter

KEYS *
KEYS *o*

...

Transaction

SET counter 1 
MULTI
INCR counter
DISCARD
GET counter
MULTI
INCR counter
INCR counter
EXEC
GET counter

Publish-Subscribe

HELP SUBSCRIBE
SUBSCRIBE whispers chatter

Start a second redis-cli

docker run --name my-redis-cli-2 -it --link my-redis:redis --rm redis redis-cli -h redis -p 6379


HELP PUBLISH
PUBLISH whispers "hello world"
PUBLISH chatter "hi"

At the end

Clean all with

docker rm -f my-redis-cli-2
docker rm -f my-redis-cli-1
docker rm -f my-redis
docker ps -a