Redis 101

Redis is an in-memory data structure store, used as a distributed, in-memory key–value database, cache and message broker, with optional durability.

in-memory: It is in-memory makes it look up. The memory is set up as one long list of addresses each of these addresses store some data. If we know the memory address then we can get the data very quickly. Redis is one long list of keys if we know the key we can get the data out very quickly. if you are coming from a classic database background there is not much of a comparison. There are no indexes either know where the data is or you do not.

Data structure store: there are multiple types of data that we can store at each key. We can store string, integer, and many more types.

Redis is a network server: Redis makes itself available for multiple devices over the network. This means Redis is essentially making another computer’s memory available and also technically the network connection is a source of most of the latency in the request for a Redis value.

Easy way to make Redis environment in Docker for CLI Test

docker run --name sample-redis -p 6379:6379 -d redis:latest
docker run -it --link sample-redis:redis --rm redis redis-cli -h redis -p 6379
redis:6379> 

Redis CLI

redis:6379> help set

  SET key value [EX seconds|PX milliseconds|KEEPTTL] [NX|XX]
  summary: Set the string value of a key
  since: 1.0.0
  group: string

redis:6379> help get

  GET key
  summary: Get the value of a key
  since: 1.0.0
  group: string

Set key and value in Redis and Get value by the key

redis:6379> set test_key "the value"
OK
redis:6379> get test_key
"the value"

Leave a Reply

Your email address will not be published.

ANOTE.DEV