9
Write A Redis Client of your own Gao Chao https://github.com/reterVision

Write a redis client of your own

Embed Size (px)

Citation preview

Page 1: Write a redis client of your own

Write A Redis Client

of your ownGao Chao

https://github.com/reterVision

Page 2: Write a redis client of your own

What is Redis

https://github.com/antirez/redis

Key-Value Store

Event Driven

redis-server: a TCP server using client-server model.

Page 3: Write a redis client of your own

Communication Protocol

*<param_count>

$<command_string_length>

command

$<param_string_length>

param

$<param_string_length>

param

….

Page 4: Write a redis client of your own

Sample Communication

Client -> Server

*3

$4

HGET

$14

test:hash

$5

hello

Server -> Client

$13

[1,2,3,4,5,6]

Page 6: Write a redis client of your own

Pipeline

*3

$4

HGET

$9

test:hash

$5

hello

(continue with left…)

*2

$7

HGETALL

$9

test:hash

Essentially is cache all the commands you want to send to redis-

server

and send them all at once when you feel good.

Page 7: Write a redis client of your own

Pipeline Response

$13

[1,2,3,4,5,6]

*2

$2

55

$13

[1,2,3,4,5,6]

<- String length of first cmd response

<- First cmd resp

<- Parameters count of second cmd resp

<- String length of 1st param of second cmd resp

<- 1st param of second cmd resp

<- String length of 2nd param of second cmd resp

<- 2nd param of second cmd resp

Page 9: Write a redis client of your own

Thank you!