Redis is an open-source, in-memory data structure store used as a:

  • Database
  • Cache
  • Message Broker
  • Streaming engine

Installation on Linux - Ubuntu

sudo apt-get update sudo apt-get install redis-server

Start redis-server as daemon

redis-server --daemonize yes


Redis Data Types

Strings

  • stores redis key with a value of type sequences of bytes, including text, serialized objects, and binary arrays
  • often used for caching but also support increments and bitwise operations

Commands

commanddescription
KEYS *get all keys
SETstores a string value
SETNXstores a string value if key doesn’y already exists, useful for implementing locks
GETretrieves a string value
MSETset multiple string values
MGETretrieve multiple string values
INCRBYatomically increments counters stored at a given key
INCRBYFLOATatomic increment for floating point numbers

JSON

  • sets a redis key with a JSON value