This is a module that I tried to understand the usage of builtin data structures and using them in the shared memory zone.
Requests are in the following format:
http://localhost/a_digit/a_number/
For each a_digit value rbtree is checked, if there isn't any node with a_digit value a new node is created. Then a_number is added to the hash table that is inside the newly created or existing rbtree node.
Since every request needs shared memory to be saved, all of the operations are done in shared memory zone.
I have used the following lines in my conf file:
server {
listen 80;
server_name localhost;
location = /tree{
print-tree;
}
location ~ ^/\d/\d+$ {
insert;
}
}
I have learned many things from Emiller's Guide. It is very nice guide for beginners.
Also I have got help from nginx-hello-world-module. It was nice to see a whole module code.
And for data structures and shared memory, I often checked the developement guide written by nginx developers.