Home > Backend Development > PHP Problem > How to set expiration time in php redis

How to set expiration time in php redis

藏色散人
Release: 2023-03-08 11:36:01
Original
11081 people have browsed it

php How to set the expiration time in redis: first open the corresponding PHP file; then set the expiration time of the redis key through "$redis->expireAt($key, $expireTime);".

How to set expiration time in php redis

#The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer.

php redis set expiration time:

PHP sets the Redis key to be valid on that day

$redis->set($key,$value);
 $expireTime = mktime(23, 59, 59, date("m"), date("d"), date("Y"));
        //设置键的过期时间
$redis->expireAt($key, $expireTime);
Copy after login

Note that if the key here is a hash data structure, it is for the key, not If the field in the hash structure is set like this, the entire hash key will also be invalid.

[Recommended learning: "PHP Video Tutorial"]

The above is the detailed content of How to set expiration time in php redis. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template