redis的数据结构
String:动态的,类似ArrayList。里边可以是字符串,数字,浮点数
List:每一个节点都有一个字符串,双向链表 0,1,2,3 -1****,-2****,-3
Set:无序字符串
Hash:<key,value> 类似Java里的hashmap
Zset(value,score)排列顺序由score决定===等价于sortedset


跳跃表
跳表是从上往下找
比如:
要找5
从第二层开始找,发现5在第二层的4和6之间,开始向下找。一直到第四层才找到
用空间找时间,查找效率较高,所以zset用跳表,是利用跳表查找的效率高
因为zset是要根据score进行排序的,取数据时需要排序,但为什么不用平衡二叉树和红黑树呢?
因为平衡二叉树需要不断调整,很麻烦的。实现起来还不如跳表简单

在实际的实现中,跳跃表内部是双向链表
网友评论