Redis

From Ever changing code
Revision as of 13:21, 17 September 2020 by Pio2pio (talk | contribs)
Jump to navigation Jump to search

This is most about AWS ElastiCache service, Redis cache that is fast key/value store.


Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes with radius queries and streams. Read more...


Install the cli client only, Ubuntu 20.04

apt install redis-tools


Test connectivity

redis-cli -h re111111111111.aaaaaa.ng.0001.cac1.cache.amazonaws.com -p 6379 ping
PONG
redis-cli -h redis.acme.com -p 6379 ping
PONG


Connect to the server and run commands from cli:

# connect to the server cli
$ redis-cli -h redis.acme.com -p 6379

# Using docker
$ docker run -it redis redis-cli -h redis.acme.com -p 6379

# Using telnet `apt install telnet`
telnet redis.acme.com 6379
Trying 10.10.10.111... # <-- server IP
Connected to redis.acme.com.
Escape character is '^]'.
monitor                     # command 1, streams back every command processed by Redis
+OK                         # stop monitoring by Ctl^C or issue command `QUIT` if using Telnet session
QUIT
+OK
Connection closed by foreign host.

telnet redis.acme.com 6379
Trying 10.10.10.111... # <-- server IP
KEYS AuthenticationService  # command 2, show keys
+1600340814.733253 [0 10.10.10.222:59730] "keys" "AuthenticationService" # <-- .222 client IP
*0
^]
telnet> Connection closed.


Commands

# list keys 'KEYS pattern'
redis.acme.com:6379> KEYS *Auth*

# set value
redis.acme.com:6379>  SET mykey 10
"OK"

# read value
redis.acme.com:6379>  DUMP mykey
"\u0000\xC0\n\t\u0000\xBEm\u0006\x89Z(\u0000\n"