美文网首页我爱编程
redis 数据结构

redis 数据结构

作者: 曹建发 | 来源:发表于2018-05-28 16:50 被阅读0次

    redis 数据结构

    redis作为key_value的数据库,有五种数据结构

    • string 二进制字符串
    • list string list
    • set string set
    • sortSet string set with float score
    • hash 注意hash的value不能嵌套,key 和 value 都是字符串类型

    另外今天翻阅官方文档An introduction to Redis data types and abstractions – Redis时注意到,redis还有 bitmap 和 hyperloglog两种类型,有点惊奇,一直以来忽略了两种redis的数据类型?
    阅读完文档后发现,后面两种其实还是string。那么单独列出来这两种有什么用?

    Bitmap

    由于redis的 string是二进制的,因此可以对每一个bit进行操作,一个string也就可以看做一个bitmap了。关于bitmap的具体操作,可以查询官方文档,这里不再举例。

    Redis keys are binary safe, this means that you can use any binary sequence as a key, from a string like "foo" to the content of a JPEG file
    

    hyperloglog

    hyperloglog是redis实现的一个基数统计算法,可以在只占用很少内存的情况下,实现较高精度的基数统计。redis提供了 PFADD,PFCOUNT,PFMERGE三个命令。

    参考文献

    神奇的HyperLogLog算法 · rainybowe
    Sketch of the Day: HyperLogLog — Cornerstone of a Big Data Infrastructure – AK Tech Blog

    相关文章

      网友评论

        本文标题:redis 数据结构

        本文链接:https://www.haomeiwen.com/subject/debgjftx.html