侧边栏壁纸
博主头像
福福不服博主等级

孩子会穿过大雨,去懂人间的道理。

  • 累计撰写 92 篇文章
  • 累计创建 98 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

Redis数据结构介绍

Monster
2023-11-27 / 0 评论 / 2 点赞 / 34 阅读 / 4000 字 / 正在检测是否收录...
温馨提示:
请确保在评论和互动中保持礼貌和尊重。避免使用侮辱性、歧视性或攻击性语言。我们鼓励建设性的讨论和意见交流。

Redis数据结构

Redis是一个key-value的数据库,key一般是String类型,不过value的类型多种多样:

  1. 字符串(String):最常见的值类型,可以存储任意长度的字符串。

  2. 哈希(Hash):一个键值对的集合,类似于关联数组或字典。每个哈希可以存储多个字段和对应的值。

  3. 列表(List):一个有序的字符串元素集合,可以在列表的两端进行插入、删除和访问操作。

  4. 集合(Set):一个无序的字符串元素集合,不允许重复元素。可以进行集合操作,如交集、并集、差集等。

  5. 有序集合(Sorted Set):类似于集合,但每个元素都关联着一个分数,用于排序和按范围查询。

  6. 地理位置(Geospatial):用于存储地理位置信息的数据类型,可以进行附近位置查询和距离计算。

除了上述数据类型,Redis还提供了一些特殊的数据结构和功能,如位图(Bitmap)、HyperLogLog、Pub/Sub(发布订阅)等。

通过使用不同的数据类型,Redis可以适应各种场景和需求,提供高效的数据存储和访问。您可以根据具体的应用需求选择适合的数据类型来存储和操作数据。

在redis-cli中要获取关于数据类型的帮助信息,可以在redis-cli中输入以下命令来获取相关帮助:(help @数据类型

127.0.0.1:6380> help @string

  APPEND key value
  summary: Appends a string to the value of a key. Creates the key if it doesn't exist.
  since: 2.0.0

  DECR key
  summary: Decrements the integer value of a key by one. Uses 0 as initial value if the key doesn't exist.
  since: 1.0.0

  DECRBY key decrement
  summary: Decrements a number from the integer value of a key. Uses 0 as initial value if the key doesn't exist.
  since: 1.0.0

  GET key
  summary: Returns the string value of a key.
  since: 1.0.0

  GETDEL key
  summary: Returns the string value of a key after deleting the key.
  since: 6.2.0

  GETEX key [EX seconds|PX milliseconds|EXAT unix-time-seconds|PXAT unix-time-milliseconds|PERSIST]
  summary: Returns the string value of a key after setting its expiration time.
  since: 6.2.0

  GETRANGE key start end
  summary: Returns a substring of the string stored at a key.
  since: 2.4.0

  GETSET key value
  summary: Returns the previous string value of a key after setting it to a new value.
  since: 1.0.0

  INCR key
  summary: Increments the integer value of a key by one. Uses 0 as initial value if the key doesn't exist.
  since: 1.0.0

  INCRBY key increment
  summary: Increments the integer value of a key by a number. Uses 0 as initial value if the key doesn't exist.
  since: 1.0.0

  INCRBYFLOAT key increment
  summary: Increment the floating point value of a key by a number. Uses 0 as initial value if the key doesn't exist.
  since: 2.6.0

  LCS key1 key2 [LEN] [IDX] [MINMATCHLEN min-match-len] [WITHMATCHLEN]
  summary: Finds the longest common substring.
  since: 7.0.0

  MGET key [key ...]
  summary: Atomically returns the string values of one or more keys.
  since: 1.0.0

  MSET key value [key value ...]
  summary: Atomically creates or modifies the string values of one or more keys.
  since: 1.0.1

  MSETNX key value [key value ...]
  summary: Atomically modifies the string values of one or more keys only when all keys don't exist.
  since: 1.0.1

  PSETEX key milliseconds value
  summary: Sets both string value and expiration time in milliseconds of a key. The key is created if it doesn't exist.
  since: 2.6.0

  SET key value [NX|XX] [GET] [EX seconds|PX milliseconds|EXAT unix-time-seconds|PXAT unix-time-milliseconds|KEEPTTL]
  summary: Sets the string value of a key, ignoring its type. The key is created if it doesn't exist.
  since: 1.0.0

  SETEX key seconds value
  summary: Sets the string value and expiration time of a key. Creates the key if it doesn't exist.
  since: 2.0.0

  SETNX key value
  summary: Set the string value of a key only when the key doesn't exist.
  since: 1.0.0

  SETRANGE key offset value
  summary: Overwrites a part of a string value with another by an offset. Creates the key if it doesn't exist.
  since: 2.2.0

  STRLEN key
  summary: Returns the length of a string value.
  since: 2.2.0

  SUBSTR key start end
  summary: Returns a substring from a string value.
  since: 1.0.0

127.0.0.1:6380> 
2
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin
  3. QQ打赏

    qrcode qq

评论区