Redis MGET 命令
发表于|更新于|Redis教程
|浏览量:
语法
1 | MGET key [key ...] |
可用版本
≥ 1.0.0
时间复杂度
$O(N)$
其中 N 是要检索的 key 的数量。
ACL类别
@read, @string, @fast
返回所有指定 key 的值。对于每个不持有字符串值或不存在的键,将返回特殊值 nil。正因为如此,该操作永远不会失败。
返回值
返回一个数组,元素由所有给定的 key 上的值组成。
示例
1 | redis> SET key1 "Hello" |
(END)
文章作者: Johnson Lin
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 Johnson Lin!
相关推荐
2023-05-31
Redis APPEND 命令
语法1APPEND key value 可用版本 ≥ 2.0.0 时间复杂度 $O(1)$ 假设附加的值很小,并且已经存在的值是任何大小,摊销后的时间复杂度是O(1),因为Redis使用的动态字符串库会在每次重新分配时将可用空间增加一倍。 如果追加的值比较小,而当前已经存在的值大小任意,那么摊销后的时间复杂度是 $O(1)$,因为 Redis 使用的动态字符串库会在每次重新分配时将可用空间增加一倍。 ACL类别 @write, @string, @fast 如果 key 已经存在并且它的值的数据类型是字符串,APPEND 命令会将 value 追加到该 key 原来的值的末尾。如果 key 不存在, APPEND 就简单地将给定 key 设为 value ,就像执行 SET key value 一样。 返回值返回一个整数,表示追加操作后,key 对应值的字符串长度。 示例 1以下例子示范了如何使用 APPEND 命令在 Redis 中追加字符串。 首先,检查 foo 键是否存在,由于返回 0,说明不存在。 然后,执行 APPEND foo "Rain",向 ...

2024-07-30
Effective Ways to Delete Fuzzy Matching Keys in Redis
In Redis, managing keys efficiently is crucial for optimal performance. Sometimes, you might need to delete keys that match a pattern or have a fuzzy match. Here’s how you can achieve this: Using Redis CLI CommandsRedis CLI provides several commands to interact with keys. To delete keys that match a pattern, you can use the KEYS command in combination with the DEL command: 1redis-cli KEYS "pattern*" | xargs redis-cli DEL Replace "pattern*" with your specific pattern. This ...
2024-10-07
Redis Set SINTERSTORE Command
The Redis SINTERSTORE command stores the intersection of the specified sets in a given destination set. If the destination set already exists, it will be overwritten. SyntaxThe basic syntax of the SINTERSTORE command is as follows: 1SINTERSTORE destination key [key ...] This command is equal to SINTER, but instead of returning the resulting set, it is stored in destination. If destination already exists, it is overwritten. Available SinceRedis version >= 1.0.0 Time ComplexityO(N*M) worst c...
2024-10-11
Redis Set SMISMEMBER Command
The Redis SMISMEMBER command returns whether each member is a member of the set stored at key. For every member, 1 is returned if the value is a member of the set, or 0 if the element is not a member of the set or if key does not exist. SyntaxThe basic syntax of the SMISMEMBER command is as follows: 1SMISMEMBER key member [member ...] Available SinceRedis version >= 6.2.0 Time ComplexityO(N) where N is the number of elements being checked for membership ACL Categories@read, @set, @fast...
2024-11-07
How to Install Redis on Ubuntu Using the APT Command
Redis is a popular, open-source, in-memory data structure store used as a database, cache, and message broker. Installing Redis on Ubuntu is straightforward, thanks to the Advanced Package Tool (APT), which simplifies installing software on Debian-based Linux systems like Ubuntu. Here’s a step-by-step guide on how to install Redis using APT. Step 1: Update Your SystemBefore installing any new software, it’s good practice to update your package lists to ensure you have the latest versions a...
2024-10-02
Redis Set SADD Command
The Redis SADD command adds one or more member elements to a set. If an element already exists in the set, it will be ignored. If the set key does not exist, a new set is created with the added elements as its members. If the key is not of the set type, an error is returned. Note: In Redis version 2.4 and earlier, the SADD command only accepts a single member value. SyntaxThe basic syntax of the SADD command is as follows: 1SADD key member [member ...] Available SinceRedis version >= 1.0.0...


