Redis Flashcards

1
Q

What happens when redis server gets turned off?

A
  • The first method is a point-in-time dump either when certain conditions are met ( For example makes snapshot only if something was written during 15 minutes )
  • The second method uses an append-only file that writes every command that alters data
    in Redis to disk as it happens.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What real cases can redis improve comparing to relational DB?

A
  • you can avoid writing unnecessary temporary data, avoid needing to scan over and delete this temporary data, and ultimately improve performance.
  • Write statistics
  • Counters
  • Write logs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What 5 redis data structure exists?

A

STRINGs, LISTs, SETs, HASHes, and ZSETs (sorted set)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to add/get/remove string value in redis?

A

set mykey ‘hello’
get mykey
del mykey

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to get/add/remove values from the redis list?

A

rpush my_list 1 2 3
lindex my_list 0 # 1
lrange my_list 0 2 # 1 2 3
lpop my_list # removes first value from the left
rpop my_list # removes first value from the right

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to get/add/remove values from the redis set?

A
sadd my_set 1
sadd my_set 2
sadd my_set 3
srem my_set 3
smembers my_set # 1 2
sismember my_set 32 # 0
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to get/add/remove values from the redis hash?

A
hset my_hash key 12
hset my_hash key2 12
hget my_hash key
hdel my_hash key
hgetall my_hash # returns all
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to implement pub/sub in redis?

A

SUBSCRIBE channel

PUBLISH channel ‘Hello message’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to use transaction in Redis?

A

MULTI
set key ‘hello’
….
EXEC

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is snapshot drawback?

A
  • Snaphot creating could stop the redis for several seconds if there too much data inside.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly