Redis CLI Basics
Published: Mar 12, 2019
Last updated: Mar 12, 2019
tl;dr
Hash Sets
| Command | Function | Example |
|---|---|---|
| HGETALL | Get all fields and values in hash | HGETALL coin:btc |
| HKEYS | Get all fields in hash | HKEYS coin:btc |
| HGET | Get value of hash field | HGET coin:btc id |
| HMGET | Multiple get value of hash field | HGET coin:btc id buy sell |
| HSET | Set value of hash field | HSET coin:btc id 1234 |
| HMSET | Multiple set value of hash field | HSET coin:btc id ID1234 buy 123 sell 100 |
Lists
| Command | Function | Example |
|---|---|---|
| RPUSH | Push elements onto a list | RPUSH list "one" |
| LPOP | Pop element from last on list | LPOP list |
| LLEN | Get list length | LLEN list |
Run local server and attach
# terminal one redis-server /usr/local/etc/redis.conf # terminal two redis-cli
Command list
| Function | Command |
|---|---|
| Install | brew install redis |
| Run server | redis-server /usr/local/etc/redis.conf |
| Uninstall | brew uninstall redis && rm ~/Library/LaunchAgents/homebrew.mxcl.redis.plist |
| Info | brew info redis |
| Run Redis CLI client | redis-cli |
Redis commands
A full list can be found at https://redis.io/commands.
Redis CLI Basics
Introduction