expireAt($key, $expireTime);"."/> expireAt($key, $expireTime);".">

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

How to set expiration time in php redis

藏色散人
藏色散人Original
2021-03-02 09:39:4210913browse

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);

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!

Statement:
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