hash表的三处使用讲解(nginx, memcache, libevent)

Libevent Book 官方教程"Programming with Libevent"英文版pdf

https://download.csdn.net/download/hdgcx/10178579

 

Nginx基础. Nginx基本哈希表

https://blog.csdn.net/u012062760/article/details/48140449#comments

description:

根据以往的学习经验, 比如STL中的哈希表, 利用开链法, vector+list作为容器, 当hashtable中的元素总数超过一定数量时, 选择扩充vector.
再比如libevent中的哈希表, 与STL中的哈希表类似, 但比较复杂, 每个bucket中都可能有一个链表,每个链表元素中也可能存在一个链表. 但理解起来都并不复杂.
现在看的Nginx中的哈希表, 则与上面谈到的哈希有很明显的不同之处.

在nginx中, 存储server_name和ngx_http_core_srv_conf_t的映射时用到了hash结构. 
配置server_names_hash_max_size可以控制bucket的最大数量,server_names_hash_bucket_size可以控制每个bucket的大小
下图, 就是nginx存储不含通配符的server_name时使用的hash结构:
                                  .............................................

memcached源码分析-----哈希表基本操作以及扩容过程

https://blog.csdn.net/luotuo44/article/details/42773231

Libevent源码分析-----event_io_map哈希表

https://blog.csdn.net/luotuo44/article/details/38403241

猜你喜欢

转载自blog.csdn.net/happylzs2008/article/details/92748820