
数据库
文章平均质量分 80
贱走偏锋
朝着梦想努力吧
展开
-
redis中SDS实现
sds(simple dynamic string)是Redis自己构建的字符串,作为Redis默认的字符串表示。/* * 类型别名,用于指向 sdshdr 的 buf 属性 */typedef char *sds;/* * 保存字符串对象的结构 */struct sdshdr { // buf 中已占用空间的长度 int len; // buf 中剩余可用空间的长度 ...原创 2018-06-23 09:18:40 · 987 阅读 · 0 评论 -
Redis之字典
Redis的字典的底层实现是用哈希表。/* This is our hash table structure. Every dictionary has two of this as we * implement incremental rehashing, for the old to the new table. */typedef struct dictht { dictEntry *...原创 2018-06-23 22:35:00 · 208 阅读 · 0 评论 -
Redis锁的介绍
Redis锁的实现:由于Redis是单进程的,可以简单用setnx这个命令进行加锁操作,谁能操作成功,谁就可以获得锁。简单的代码如下:def acquire_lock(): # identifier: 唯一标识客户端 # lockname 锁名字 # redis 客户端连接 if redis.setnx(lockname, identifier): ...原创 2018-08-20 18:24:02 · 2530 阅读 · 2 评论