redis中的"HashMap"
redis是一个存储键值对的内存数据库,其存储键值的方式和java中的HashMap相似。 表征redis数据库的结构体是redisDb (在server.h文件中),redis服务器默认有16个数据库,编号从0到15。 typedef struct redisDb { dict *dict; /* 键空间 */ dict *expires; /* 过期键空间 */ dict *blocking_keys; /* 客户端在等待的键 (BLPOP) */ dict *ready_keys; /* 接收到 push 的阻塞键 */ dict *watched_keys; /* WATCHED keys for MULTI/EXEC CAS */ struct evictionPoolEntry *eviction_pool; /* Eviction pool of keys */ int id; /* Database ID */ long long avg_ttl; /* Average TTL, just for stats */ } redisDb; dict 中存储的是 key -> value,而expires存储的 key -> 过期时间 dict是dict.h文件中定义的结构体: typedef struct dict { dictType * type; void *