Redis Basic Commands

Big O(1) Case: If you have one key or you have a million keys when you run to get it will take the same amount of time to find that key.

Basic – Commands

Get and Set

redis:6379> set user1 tim
OK
redis:6379> get user1
"tim"

Increment

redis:6379> set counter 1
OK
redis:6379> incr counter
(integer) 2
redis:6379> get counter
"2"

Check the key is exists

redis:6379> exists user1
(integer) 1

Expire after 10 seconds

redis:6379> expire user1 10
(integer) 1
redis:6379> get user1
(nil)

Set key and value with expire time 100 seconds

redis:6379> set user1 tim EX 100
OK
redis:6379> ttl user1
(integer) 99
redis:6379> ttl user1
(integer) 98
redis:6379> ttl user1
(integer) 97
redis:6379> ttl user1
(integer) 96

https://redis.io/commands

Leave a Reply

Your email address will not be published.

ANOTE.DEV