: This article mainly introduces the implementation of the redis sender. if you are interested in the PHP Tutorial, please refer to it. The auto increment auto-increment id value of mysql may leak some sensitive data.
For example, if the user_id of the user table is auto-incrementing, the id value displayed in the url may expose the actual number of users on the website.
The following code uses php and redis's incrby to implement a simple sender:
Function get_id ($ type, $ server_ip, $ server_port, $ key) {$ init_num = 0; $ redis = new Redis (); $ redis-> connect ($ server_ip, $ server_port); $ var = $ redis-> exists ($ key); if ($ var = 0) {$ redis-> set ($ key, $ init_num );} $ incr_num = rand (); // the incremental value is a random number $ var = $ redis-> incrby ($ key, $ incr_num); $ redis-> close (); return $ var ;}
The above introduces the implementation of the redis sender, including the content, hope to be helpful to friends interested in the PHP Tutorial.