Explore Redis using redis-cli

imran ali
2 min readJun 19, 2019

--

Few things you may know about Redis.

  • Redis stands for REmote DIctionary Server.
  • It is an opern source advance key-value database, where key can contain data structures such as strings, hashes, lists, sets and sorted sets etc. it is also NoSQL database.
  • It can be used as Database ( can persist data to disk), Caching layer ( it is fast & light weight) or a Message broker.
  • Redis is single threaded server, not design for multiple cpu cores, to scale out you can launch several instances for Redis server.
  • All operations are atomic not more than two commands run together.
  • In redis values can not be bigger than 512MB.

Redis instalation

you can go and download form redis.io, or you can use Homebrew it will reduce cost of settings.

brew install redis

and you are done.

Run redis server: open terminal and run command

redis-server

it will run redis server on default port 6379 and listen, if you want to run on other port use command

redis-server — port <port-number>

Run redis cli : open another terminal and run command

redis-cli

it will connect redis server on default port 6379 if you want to connect on other port run this command

redis-cli -p <port-number>

After connection you can use any of commands, like SET, GET, EXPIR , SUBSCRIBE, PUBLISHetc like below, redis command documents you can find here.

redis-cli pingwill return PONG that will confirm you redis server is running, redis-cli shutdown will shutdown your redis-server.

Thanks for reading.

--

--