A lecture about a client for Redis that I'm writing, and it's hardships that I encountered.
This lecture and slides should be used only in humor, and should not be viewed with different light
2. 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 !
4. 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
5. Ah, yes, but what is Redis ?
Hello my name is
REmote Dictionary Server
prepare to die
6.
7. OK, it's a Key Value database
Are you happy now ?
8. 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 ...)
9. 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,
10. 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
11.
12. 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 !
13. Can you show us an example ?
…
var
my_command : TRedisAbstractCommands;
…
writeln(my_command.ParamsToStr(['a', 3.14,
False]));
…
(* output as string :
arn3.14rnFalsern *)
14.
15. 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”
16. Data types
TPersistent
TRedisReturnType
TRedisNullReturnType TRedisNumericReturnType
TRedisStatusReturnType TRedisErrorReturnType
TRedisMultiBulkReturnTyp
TRedisBulkReturnType
e
17. There shell be a command !
TRedisObject
TRedisParser TRedisAbstractCommands
Command group Command group Command group Command group
Command group Command group
18. Few more words regarding commands
Every new version of Redis has new/changes to
commands.
Can't support such changes for long time
So I 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...
20. 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