redis expiration time
Introduction to redis expiration time Sometimes we don’t want the redis key to always exist. For example, cache, verification code and other data, we hope that they can be automatically destroyed within a certain period of time. Redis provides some commands that allow us to set the expiration time for the key and let the key be automatically deleted after it expires.
redis expiration time related commands
1.EXPIRE PEXPIREEXPIRE interfaceDefinition: EXPIRE key "seconds" Interface description: Set a key to expire after the current time "seconds". Returning 1 means the setting is successful, returning 0 means the key does not exist or the expiration time cannot be set. PEXPIRE interface definition: PEXPIRE key "milliseconds" interface description: Set a key to expire after the current time "milliseconds" (milliseconds). Returning 1 means the setting is successful, returning 0 means the key does not exist or the expiration time cannot be set.
2.EXPIREAT PEXPIREATE Returning 1 means the setting is successful, returning 0 means the key does not exist or the expiration time cannot be set. PEXPIREAT interface definition: PEXPIREAT key "milliseconds-timestamp" interface description: Set a key to expire after "milliseconds-timestamp" (timestamp (milliseconds)). Returning 1 means the setting is successful, returning 0 means the key does not exist or the expiration time cannot be set
3.TTL PTTLTTL interface Definition: TTL key interface description: Get the expiration time of the key. If the key has an expiration time, return the remaining survival time (seconds); if the key is permanent, return -1; if the key does not exist or has expired, return -2. PTTL interface definition: PTTL key interface description: Get the expiration time of the key. If the key has an expiration time, the remaining survival time (milliseconds) is returned; if the key is permanent, -1 is returned; if the key does not exist or has expired, -2 is returned.
4.PERSISTPERSIST interface Definition: PERSIST key interface description: Remove the expiration time of the key and convert it to a permanent state. If 1 is returned, the conversion is successful. If 0 is returned, it means that the key does not exist or has been in a permanent state before.
5.SETEXSETEX interfaceDefinition: SETEX key "seconds" "value" interface description: SETEX is logically equivalent to the operation of SET and EXPIRE merging, the difference is that SETEX is a command, and the execution of the command is atomic, so there will be no concurrency problems.
The above is the detailed content of What is the general redis cache time?. For more information, please follow other related articles on the PHP Chinese website!

Redis是现在最热门的key-value数据库,Redis的最大特点是key-value存储所带来的简单和高性能;相较于MongoDB和Redis,晚一年发布的ES可能知名度要低一些,ES的特点是搜索,ES是围绕搜索设计的。

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了关于redis的一些优势和特点,Redis 是一个开源的使用ANSI C语言编写、遵守 BSD 协议、支持网络、可基于内存、分布式存储数据库,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了Redis Cluster集群收缩主从节点的相关问题,包括了Cluster集群收缩概念、将6390主节点从集群中收缩、验证数据迁移过程是否导致数据异常等,希望对大家有帮助。

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了Redis实现排行榜及相同积分按时间排序,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,希望对大家有帮助。

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了关于原子操作中命令原子性的相关问题,包括了处理并发的方案、编程模型、多IO线程以及单命令的相关内容,下面一起看一下,希望对大家有帮助。

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了bitmap问题,Redis 为我们提供了位图这一数据结构,位图数据结构其实并不是一个全新的玩意,我们可以简单的认为就是个数组,只是里面的内容只能为0或1而已,希望对大家有帮助。

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了Redis实现排行榜及相同积分按时间排序,本文通过实例代码给大家介绍的非常详细,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了关于实现秒杀的相关内容,包括了秒杀逻辑、存在的链接超时、超卖和库存遗留的问题,下面一起来看一下,希望对大家有帮助。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
