redis - from client to execution
TRANSCRIPT
From Client to developer execution
Disclaimer
Disclaimer
This lecture and slides should be used only in humor, and that's how it should be understood
If you find it offensive in any way, please do not use this slides, and go out from the lecture !
What does people think Redis is ?
So what is Redis ?
Open source in memory fast binary safe database that support the following:Key Value information
Arrays/Lists and nested lists
Sets/Sorted Sets
Hashes
Type of Message Queue
Distributed work
Ah, yes, but what is Redis ?
Hello my name is REmote Dictionary Server
prepare to die
OK, it's a Key Value databaseAre you happy now ?
How I met Redis ?
I needed to use it with an Object Pascal based Project, and there was no Object Pascal client
So I started to work on one:https://github.com/ik5/redis_client.fpc
And I still do (when I have free time ...)
What is the first rule of Redis ?
You do not talk about Redis
Redis's developer created most client libraries that exists today
The documentation that you see, well it's can be better:What you read and what that is implemented are different things (sometimes)
There are a lot of missing information, that only trial and
error teaches you about them
It is written in plain C for better and worse
The developer of Redis is not very communicative person imho ...
So how do you write a client for Redis ?
Reading the Protocol documentation (well, duh )
Finding that some of the real implementation is different then the protocol itself
Wishing a slow death to the developer
Bitching about it at your blog (posts)
Asking yourself: why don't you use a dynamic programming language ...
Sitting down and solving the problems
Why ?
It's very readable programming language
It's string types (yes in plural) are easy to use
Because it is one of the best compiled programming languages
ever existed
Because I can !
Can you show us an example ?
var my_command : TRedisAbstractCommands;
writeln(my_command.ParamsToStr(['a', 3.14, False]));(* output as string : a\r\n3.14\r\nFalse\r\n *)
In soviet Russia several ways implement you
Four ways to implement the client:Thinking like dynamic language (but code in Pascal)
Thinking in C (but code in Pascal)
Thinking in Java/C# (but code in Pascal)
Think in Pascal
I read few implementation of the clients:
Lua, Ruby, Perl, Python, Java and C
Decided on the 4th way as the proper way
Research and documentation
by me on each command !
To infinity and beyond
Data types
TRedisReturnTypeTRedisNullReturnTypeTRedisStatusReturnTypeTRedisErrorReturnTypeTRedisNumericReturnTypeTRedisBulkReturnTypeTRedisMultiBulkReturnType
TPersistent
There shalt be a command !
TRedisObjectTRedisParserTRedisAbstractCommands
Command groupCommand groupCommand groupCommand groupCommand groupCommand group
Few more words regarding commands
Every new version of Redis has new/changes to commands.
Can't support such changes for long time
My library helping you, by allowing you to call commands, never
existed when I wrote the client, without going insane !
OK, You might go insane, but not because of my library...
Sockets
TSynaClientTRedisIO
Debug, Errors and log files
Each class can have it's own log file for debug/error or no file at all !
You can use also the same logger for every class
Your own error handlers using callbacks, or just let exception raise up
The final slide
Should we use Redis ?
The final slide
Should we use Redis ?
Oh fuck, it's a Perl lecture, I forgot to add some details on that ...
Redis and Perl
main module: https://metacpan.org/module/Redis
some benchmarks: http://blogs.perl.org/users/wolfgang_kinkeldei/2012/01/perl-is-faster-than-c----can-benchmarks-get-compared.html
servers, plugins, and interesting stuff:https://metacpan.org/module/Redis::Queue
https://metacpan.org/module/Nginx::Redis
https://metacpan.org/module/Redis::hiredis
https://metacpan.org/module/Redis::Client
https://metacpan.org/module/AnyEvent::Redis
https://metacpan.org/module/Protocol::Redis
https://metacpan.org/module/Tie::Redis
https://metacpan.org/module/MojoX::Redis
https://metacpan.org/module/Test::Mock::Redis
https://metacpan.org/module/Dancer::Plugin::Redis
https://metacpan.org/module/RedisDB
https://metacpan.org/module/App::redisp
https://metacpan.org/module/AnyEvent::Hiredis
The final slide
Right, so what did I asked ?
The final slide
Should we use Redis ?
ABCYes
No
All of the above
Credits
Angry bird
Excited
Bored
MemCached
Redis
Buzz Lightyear
Questions ?