Redis

Setup

Docker

# pull the image from docker hub
$ docker run --name redis-learn -p 6370:6370 -d redis 

# connect to container and redis shell
$ docker exec -it redis-learn redis-cli

To benchmark

docker exec -it redis-learn redis-benchmark -n 1000 -d 10000
# -d for bytes of data

redis-benchmark -n 1000 -d 10000

To set max memory limit

> config set maxmemory 128M

Set & Get value

  • set key value

  • get key value

  • check whether key exists, returns integer

    • 0 - false | 1 - true

  • Get all keys

  • Delete all keys ( sync | async )

Set key with expiry time

Delete Key

Set & Get multiple values

Miscellaneous

Maths operations

Lists in Redis

Sorting List

Sets in Redis

Sorted Set Redis

Hashes in Redis

Transaction

Pub/Sub

  • If no one is sub to the channel you specify in publish, it returns 0

GeoSpatial Data

Last updated

Was this helpful?