关于redis:redis学习

4次阅读

共计 670 个字符,预计需要花费 2 分钟才能阅读完成。

根本类型

字符串

Hash

临时依照对象了解

命令有

  • HMSET
  • HGET
  • HGETALL

List 列表

Redis 列表是简略的字符串列表,依照插入程序排序。你能够增加一个元素到列表的头部(右边)或者尾部(左边)。

Set

string 类型的无序组合。成员不容许反复

  • sadd
  • smembers

zset

zset 是有序汇合。

每个元素关联一个 double 类型的分数。

成员为 1,分数能够是雷同的

命令

zadd

zadd key score member

key 操作

  • DEL 删除
  • exists 是否存在
  • expire 设置过期工夫,这个过期工夫单位是秒
  • expireat 过期,参数是 unix 工夫戳
  • pexpire 以毫秒工夫过期
  • keys
  • PERSIST 移除残余的工夫,该 key 变为长久放弃
  • pttl 以毫秒为单位,返回 key 的剩余时间
  • ttl 以秒为单位,返回 key 的剩余时间
  • randomkey 随即返回一个 key
  • rename 重命名 rename key newkey
  • type 返回 key 的类型
  • renamenx
const result = await redis.exists('foo');

// 返回 1 有,0 没有

await redis.keys('f*o'); // => ['foo']
await redis.exipre(1)

await redis.pttl('foo');// 1000

await redis.rename('foo','foo0')

https://www.runoob.com/redis/redis-keys.html

https://cloud.tencent.com/developer/article/1112627

正文完
 0