Redis PSETEX 命令
发表于|更新于|Redis教程
|浏览量:
从 Redis 2.6.12 版本开始,此命令被视为已弃用。
在迁移或编写新的代码时,可以将其替换为带有PX参数的SET命令。
语法
1 | PSETEX key milliseconds value |
可用版本
≥ 2.6.0
时间复杂度
$O(1)$
ACL类别
@write, @string, @slow
PSETEX 的工作方式与 SETEX 完全一样,唯一的区别是过期时间是以毫秒而不是以秒为单位。
返回值
总是返回 "OK"
示例
1 | redis> PSETEX mykey 1000 "Hello" |
(END)
文章作者: Johnson Lin
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 Johnson Lin!
相关推荐
2024-07-29
A set of best practices and guidelines for using Redis effectively
In this article, I introduce you to 12 specifications in the areas of key-value pair usage, command usage, and data preservation, centered around the goals of high-performance access and saving memory space in Redis applications. Key-Value Pair Usage Specifications [Recommended] Use the business name as the KEY prefix, preferably using its abbreviation. This is done by prefixing the business name, then separating it with a colon(:), followed by the specific business data name. For example, if...

2022-08-25
【Redis】flushall命令——清空所有缓存数据
如何清空 Redis 集群的所有缓存数据?即删除所有数据库的所有 key。 使用 Redis 的 flushall 命令。 该命令适用 Redis 版本:≥ 1.0.0 执行结果总是返回:OK。 NOTE:生产环境谨慎操作!!!除非你很清楚自己正在做什么! 具体步骤如下: 在终端命令行窗口,输入连接 Redis 指令: 1redis-cli -h 192.168.182.227 -p 1379 参数说明: -h:Redis Host(连接地址,如果连接地址为 127.0.0.1,可忽略该参数); -p:Redis Port(端口号,如果端口号为 6379,可忽略该参数); -a:Redis 连接密码(如有密码的话,需要上该参数,如 -a 1234567890k) 连接成功后,输入 flushall 指令即可清空 Redis 所有缓存数据: 1flushall 示例: 123$ redis-cli -h 192.168.182.227 -p 1379192.168.182.227:1379> flushallOK (END)
2024-11-03
Redis HyperLogLog
HyperLogLog is a probabilistic data structure used to estimate the cardinality of a set. As a probabilistic data structure, HyperLogLog trades perfect accuracy for efficient space utilization. Redis added the HyperLogLog data structure in version 2.8.9. HyperLogLog in Redis is an algorithm used for cardinality estimation. Its main advantage is that, even when the number of input elements is extremely large, the memory required to calculate the cardinality remains fixed and small. In Redis, ...
2024-11-06
Redis HyperLogLog PFCOUNT Command
The Redis PFCOUNT command returns the cardinality estimate of the given HyperLogLog. SyntaxThe basic syntax of the PFCOUNT command is as follows: 1PFCOUNT key [key ...] Available SinceRedis version 2.8.9 and later. Time Complexity O(1) when called with a single key. O(N) when called with multiple keys, where N is the number of keys. ACL Categories@read, @hyperloglog, @slow Return ValueAn integer representing the cardinality of the given HyperLogLog. If multiple HyperLogLogs are provided, r...
2024-10-19
Redis Bitmaps
In Redis, a bitmap is a data structure that represents a sequence of bits (0s and 1s). Each bit in the bitmap can be either on (1) or off (0), allowing it to represent binary data in a compact form. This is particularly useful when you need to handle large sets of boolean data, as bitmaps allow you to store information in a very space-efficient way. For example, if you have a system tracking whether users have completed a daily task, a bitmap can efficiently store whether each user has comple...
2024-09-18
Bulk Deleting Keys in Redis Using Wildcards
Be Cautious with the KEYS Command in Production: Commands like KEYS, FLUSHALL, and FLUSHDB can block Redis when working with large datasets. They may scan the entire keyspace, potentially locking up Redis and degrading performance. Redis currently does not support bulk deletion of keys using wildcards. However, we can achieve this using the del command in combination with Linux pipes and the xargs command. The del command in Redis allows you to delete one or more specified keys a...


