php redis method to implement scheduled tasks: 1. Modify the content of the configuration file redis.conf to "notify-keyspace-events "Ex""; 2. Restart the redis service; 3. Pass "object(Redis)#1(0){}string(22) "__keyevent@*__:expired"string(22) "__keyevent@0__:expire..." Just implement scheduled tasks.
php redis implements scheduled tasks
Modify the configuration file redis.conf
1 |
|
to
1 |
|
Note:
1.Linux normal configuration
2. Configure under windows, `notify-keyspace-events ""` does not have previous comments by default. You can choose to modify it directly here or comment out the current line and go up Find the comment in front of `; notify-keyspace-events "Ex"` and open it
3. Restart the redis service
php demo.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
Start the test
php demo.php
Result after 3 seconds
1 2 3 4 5 |
|
redis-cli
1 |
|
The above is the detailed content of How to implement scheduled tasks in php redis. For more information, please follow other related articles on the PHP Chinese website!