{"id":64210,"date":"2026-01-23T00:48:28","date_gmt":"2026-01-22T16:48:28","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/64210.html"},"modified":"2026-01-23T00:48:28","modified_gmt":"2026-01-22T16:48:28","slug":"%e5%ae%9e%e7%8e%b0%e5%8f%91%e9%80%81%e7%9f%ad%e4%bf%a1%e9%aa%8c%e8%af%81%e7%a0%81%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/64210.html","title":{"rendered":"\u5b9e\u73b0\u53d1\u9001\u77ed\u4fe1\u9a8c\u8bc1\u7801\u529f\u80fd"},"content":{"rendered":"<h3>\u4e00\u3001\u524d\u8a00&#xff1a;\u77ed\u4fe1\u9a8c\u8bc1\u7801 \u2260 \u8c03\u4e2a\u63a5\u53e3\u90a3\u4e48\u7b80\u5355&#xff01;<\/h3>\n<p>\u5f88\u591a\u5f00\u53d1\u8005\u8ba4\u4e3a&#xff1a;\u201c\u53d1\u77ed\u4fe1\u9a8c\u8bc1\u7801\u4e0d\u5c31\u662f\u8c03\u4e2a\u7b2c\u4e09\u65b9 API \u5417&#xff1f;\u201d<br \/>\n\u4f46\u771f\u5b9e\u751f\u4ea7\u73af\u5883\u4e2d&#xff0c;\u4f60\u5fc5\u987b\u8003\u8651&#xff1a;<\/p>\n<ul>\n<li>\u274c \u7528\u6237\u75af\u72c2\u70b9\u51fb\u201c\u83b7\u53d6\u9a8c\u8bc1\u7801\u201d&#xff0c;\u5bfc\u81f4\u77ed\u4fe1\u8d39\u7528\u98d9\u5347<\/li>\n<li>\u274c \u9ed1\u4ea7\u7528\u811a\u672c\u6279\u91cf\u6ce8\u518c&#xff0c;\u6d88\u8017\u7cfb\u7edf\u8d44\u6e90<\/li>\n<li>\u274c \u9a8c\u8bc1\u7801\u88ab\u66b4\u529b\u7834\u89e3&#xff0c;\u8d26\u53f7\u88ab\u76d7<\/li>\n<li>\u274c \u540c\u4e00\u624b\u673a\u53f7\u9891\u7e41\u8bf7\u6c42&#xff0c;\u5f71\u54cd\u6b63\u5e38\u7528\u6237<\/li>\n<\/ul>\n<p>\u4e00\u4e2a\u5065\u58ee\u7684\u77ed\u4fe1\u9a8c\u8bc1\u7801\u529f\u80fd&#xff0c;\u6838\u5fc3\u4e0d\u5728\u201c\u53d1\u77ed\u4fe1\u201d&#xff0c;\u800c\u5728\u201c\u63a7\u9891 &#043; \u5b89\u5168 &#043; \u6821\u9a8c\u201d\u3002<\/p>\n<p>\u672c\u6587\u5c06\u5e26\u4f60\u7528\u00a0Spring Boot &#043; Redis\u00a0\u5b9e\u73b0\u4e00\u5957\u53ef\u76f4\u63a5\u7528\u4e8e\u751f\u4ea7\u73af\u5883\u7684\u77ed\u4fe1\u9a8c\u8bc1\u7801\u7cfb\u7edf&#xff0c;\u5305\u542b&#xff1a;<br \/>\n\u2705 \u56fe\u5f62\u9a8c\u8bc1\u7801\u524d\u7f6e\u6821\u9a8c<br \/>\n\u2705 \u6ed1\u52a8\u7a97\u53e3\u9650\u6d41&#xff08;IP &#043; \u624b\u673a\u53f7\u53cc\u7ef4\u5ea6&#xff09;<br \/>\n\u2705 \u9a8c\u8bc1\u7801\u5b58\u50a8\u4e0e\u81ea\u52a8\u8fc7\u671f<br \/>\n\u2705 \u4e00\u6b21\u6027\u4f7f\u7528 &#043; \u9632\u91cd\u653e<br \/>\n\u2705 \u5b8c\u6574\u4ee3\u7801\u793a\u4f8b<\/p>\n<hr \/>\n<h3>\u4e8c\u3001\u6574\u4f53\u8bbe\u8ba1\u6d41\u7a0b\u56fe<\/h3>\n<p>\u7528\u6237\u70b9\u51fb\u3010\u83b7\u53d6\u9a8c\u8bc1\u7801\u3011<br \/>\n        \u2193<br \/>\n[1] \u524d\u7aef\u643a\u5e26\u56fe\u5f62\u9a8c\u8bc1\u7801 token<br \/>\n        \u2193<br \/>\n[2] \u540e\u7aef\u6821\u9a8c\u56fe\u5f62\u9a8c\u8bc1\u7801&#xff08;\u9632\u6b62\u673a\u5668\u5237&#xff09;<br \/>\n        \u2193<br \/>\n[3] \u68c0\u67e5 IP \u4eca\u65e5\u53d1\u9001\u6b21\u6570&#xff08;\u9632\u4ee3\u7406\u5237&#xff09;<br \/>\n        \u2193<br \/>\n[4] \u68c0\u67e5\u8be5\u624b\u673a\u53f7 60 \u79d2\u5185\u662f\u5426\u5df2\u53d1\u9001&#xff08;\u9632\u9891\u7e41\u70b9&#xff09;<br \/>\n        \u2193<br \/>\n[5] \u751f\u6210 6 \u4f4d\u968f\u673a\u7801&#xff0c;\u5b58\u5165 Redis&#xff08;5\u5206\u949f\u6709\u6548&#xff09;<br \/>\n        \u2193<br \/>\n[6] \u8c03\u7528\u77ed\u4fe1\u5e73\u53f0&#xff08;\u963f\u91cc\u4e91\/\u817e\u8baf\u4e91\u7b49&#xff09;\u53d1\u9001<br \/>\n        \u2193<br \/>\n[7] \u8fd4\u56de\u6210\u529f&#xff08;\u524d\u7aef\u5f00\u59cb\u5012\u8ba1\u65f6&#xff09;<br \/>\n        \u2193<br \/>\n\u7528\u6237\u63d0\u4ea4\u8868\u5355 &#043; \u9a8c\u8bc1\u7801<br \/>\n        \u2193<br \/>\n[8] \u6821\u9a8c\u9a8c\u8bc1\u7801\u662f\u5426\u6b63\u786e &amp; \u672a\u8fc7\u671f &amp; \u672a\u4f7f\u7528<br \/>\n        \u2193<br \/>\n[9] \u9a8c\u8bc1\u901a\u8fc7&#xff0c;\u6267\u884c\u4e1a\u52a1\u903b\u8f91&#xff08;\u6ce8\u518c\/\u767b\u5f55\/\u627e\u56de\u5bc6\u7801&#xff09;<\/p>\n<hr \/>\n<h3>\u4e09\u3001\u6280\u672f\u9009\u578b<\/h3>\n<table>\n<tr>\u7ec4\u4ef6\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>Spring Boot 3.x<\/td>\n<td>Web \u6846\u67b6<\/td>\n<\/tr>\n<tr>\n<td>Redis<\/td>\n<td>\u5b58\u50a8\u9a8c\u8bc1\u7801\u3001\u9650\u6d41\u8ba1\u6570\u5668<\/td>\n<\/tr>\n<tr>\n<td>StringRedisTemplate<\/td>\n<td>\u64cd\u4f5c Redis&#xff08;\u5b57\u7b26\u4e32\u53cb\u597d&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>Kaptcha \/ EasyCaptcha<\/td>\n<td>\u751f\u6210\u56fe\u5f62\u9a8c\u8bc1\u7801&#xff08;\u672c\u6587\u7528 EasyCaptcha&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u7b2c\u4e09\u65b9\u77ed\u4fe1\u5e73\u53f0<\/td>\n<td>\u963f\u91cc\u4e91\u77ed\u4fe1\u3001\u817e\u8baf\u4e91\u77ed\u4fe1\u7b49<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u56db\u3001\u6838\u5fc3\u5b9e\u73b0\u6b65\u9aa4<\/h3>\n<h4>1. \u6dfb\u52a0\u4f9d\u8d56<\/h4>\n<p>&lt;dependency&gt;<br \/>\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;<br \/>\n    &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;<br \/>\n&lt;\/dependency&gt;<br \/>\n&lt;dependency&gt;<br \/>\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;<br \/>\n    &lt;artifactId&gt;spring-boot-starter-data-redis&lt;\/artifactId&gt;<br \/>\n&lt;\/dependency&gt;<br \/>\n&lt;!&#8211; \u56fe\u5f62\u9a8c\u8bc1\u7801 &#8211;&gt;<br \/>\n&lt;dependency&gt;<br \/>\n    &lt;groupId&gt;com.github.whvcse&lt;\/groupId&gt;<br \/>\n    &lt;artifactId&gt;easy-captcha&lt;\/artifactId&gt;<br \/>\n    &lt;version&gt;1.6.2&lt;\/version&gt;<br \/>\n&lt;\/dependency&gt;<\/p>\n<hr \/>\n<h4>2. Redis Key \u547d\u540d\u89c4\u8303&#xff08;\u91cd\u8981&#xff01;&#xff09;<\/h4>\n<p>\/\/ \u9a8c\u8bc1\u7801\u5b58\u50a8<br \/>\nsms:code:{phone} \u2192 value &#061; &#034;123456&#034;<\/p>\n<p>\/\/ \u624b\u673a\u53f7\u53d1\u9001\u9891\u7387\u63a7\u5236&#xff08;60\u79d2\u5185\u53ea\u80fd\u53d11\u6b21&#xff09;<br \/>\nsms:limit:phone:{phone} \u2192 value &#061; &#034;1&#034; (\u5e26 TTL 60s)<\/p>\n<p>\/\/ IP \u53d1\u9001\u6b21\u6570\u9650\u5236&#xff08;\u6bcf\u5929\u6700\u591a20\u6b21&#xff09;<br \/>\nsms:limit:ip:{ip} \u2192 value &#061; \u8ba1\u6570&#xff08;\u5e26 TTL 24h&#xff09;<\/p>\n<hr \/>\n<h4>3. \u56fe\u5f62\u9a8c\u8bc1\u7801\u751f\u6210\u63a5\u53e3<\/h4>\n<p>&#064;RestController<br \/>\npublic class CaptchaController {<\/p>\n<p>    &#064;GetMapping(&#034;\/captcha&#034;)<br \/>\n    public void captcha(HttpServletRequest request, HttpServletResponse response) throws Exception {<br \/>\n        \/\/ \u751f\u6210\u9a8c\u8bc1\u7801&#xff08;4\u4f4d\u6570\u5b57&#xff09;<br \/>\n        ArithmeticCaptcha captcha &#061; new ArithmeticCaptcha(130, 48);<br \/>\n        captcha.setLen(4);<\/p>\n<p>        \/\/ \u5c06\u9a8c\u8bc1\u7801\u5b58\u5165 Session&#xff08;\u6216 Redis&#xff0c;\u6b64\u5904\u7b80\u5316\u7528 Session&#xff09;<br \/>\n        request.getSession().setAttribute(&#034;captcha&#034;, captcha.text());<\/p>\n<p>        \/\/ \u8f93\u51fa\u56fe\u7247<br \/>\n        response.setContentType(&#034;image\/png&#034;);<br \/>\n        captcha.out(response.getOutputStream());<br \/>\n    }<br \/>\n}<\/p>\n<p>\u2705 \u524d\u7aef\u8bbf\u95ee\u00a0\/captcha\u00a0\u83b7\u53d6\u56fe\u7247&#xff0c;\u63d0\u4ea4\u65f6\u643a\u5e26\u7528\u6237\u8f93\u5165\u7684\u7b97\u672f\u7ed3\u679c\u3002<\/p>\n<hr \/>\n<h4>4. \u53d1\u9001\u77ed\u4fe1\u9a8c\u8bc1\u7801\u63a5\u53e3&#xff08;\u6838\u5fc3&#xff01;&#xff09;<\/h4>\n<p>&#064;RestController<br \/>\npublic class SmsController {<\/p>\n<p>    &#064;Autowired<br \/>\n    private StringRedisTemplate redisTemplate;<\/p>\n<p>    private static final String SMS_CODE_KEY_PREFIX &#061; &#034;sms:code:&#034;;<br \/>\n    private static final String SMS_PHONE_LIMIT_PREFIX &#061; &#034;sms:limit:phone:&#034;;<br \/>\n    private static final String SMS_IP_LIMIT_PREFIX &#061; &#034;sms:limit:ip:&#034;;<\/p>\n<p>    &#064;PostMapping(&#034;\/send-sms-code&#034;)<br \/>\n    public ResponseEntity&lt;String&gt; sendSmsCode(<br \/>\n            &#064;RequestParam String phone,<br \/>\n            &#064;RequestParam String captchaInput,<br \/>\n            HttpServletRequest request) {<\/p>\n<p>        \/\/ 1. \u6821\u9a8c\u624b\u673a\u53f7\u683c\u5f0f<br \/>\n        if (!isValidPhone(phone)) {<br \/>\n            return ResponseEntity.badRequest().body(&#034;\u624b\u673a\u53f7\u683c\u5f0f\u9519\u8bef&#034;);<br \/>\n        }<\/p>\n<p>        \/\/ 2. \u6821\u9a8c\u56fe\u5f62\u9a8c\u8bc1\u7801<br \/>\n        String sessionCaptcha &#061; (String) request.getSession().getAttribute(&#034;captcha&#034;);<br \/>\n        if (sessionCaptcha &#061;&#061; null || !sessionCaptcha.equals(captchaInput)) {<br \/>\n            return ResponseEntity.badRequest().body(&#034;\u56fe\u5f62\u9a8c\u8bc1\u7801\u9519\u8bef&#034;);<br \/>\n        }<\/p>\n<p>        String clientIp &#061; getClientIP(request);<\/p>\n<p>        \/\/ 3. \u68c0\u67e5 IP \u65e5\u9650\u989d&#xff08;\u4f8b\u5982\u6bcf\u5929\u6700\u591a20\u6b21&#xff09;<br \/>\n        String ipLimitKey &#061; SMS_IP_LIMIT_PREFIX &#043; clientIp;<br \/>\n        Integer ipCount &#061; getRedisCount(ipLimitKey, 24 * 3600);<br \/>\n        if (ipCount &gt;&#061; 20) {<br \/>\n            return ResponseEntity.status(429).body(&#034;\u64cd\u4f5c\u8fc7\u4e8e\u9891\u7e41&#xff0c;\u8bf7\u660e\u5929\u518d\u8bd5&#034;);<br \/>\n        }<\/p>\n<p>        \/\/ 4. \u68c0\u67e5\u8be5\u624b\u673a\u53f7\u662f\u542660\u79d2\u5185\u5df2\u53d1\u9001<br \/>\n        String phoneLimitKey &#061; SMS_PHONE_LIMIT_PREFIX &#043; phone;<br \/>\n        Boolean isPhoneLimited &#061; redisTemplate.hasKey(phoneLimitKey);<br \/>\n        if (Boolean.TRUE.equals(isPhoneLimited)) {<br \/>\n            return ResponseEntity.status(429).body(&#034;\u8bf760\u79d2\u540e\u518d\u8bd5&#034;);<br \/>\n        }<\/p>\n<p>        \/\/ 5. \u751f\u62106\u4f4d\u968f\u673a\u9a8c\u8bc1\u7801<br \/>\n        String code &#061; String.valueOf((int) ((Math.random() * 9 &#043; 1) * 100000));<\/p>\n<p>        \/\/ 6. \u5b58\u5165 Redis&#xff08;5\u5206\u949f\u6709\u6548&#xff09;<br \/>\n        redisTemplate.opsForValue().set(SMS_CODE_KEY_PREFIX &#043; phone, code, 5, TimeUnit.MINUTES);<\/p>\n<p>        \/\/ 7. \u8bbe\u7f6e\u9650\u6d41\u6807\u8bb0&#xff08;60\u79d2&#xff09;<br \/>\n        redisTemplate.opsForValue().set(phoneLimitKey, &#034;1&#034;, 60, TimeUnit.SECONDS);<\/p>\n<p>        \/\/ 8. \u66f4\u65b0 IP \u8ba1\u6570<br \/>\n        redisTemplate.opsForValue().increment(ipLimitKey);<br \/>\n        redisTemplate.expire(ipLimitKey, 24, TimeUnit.HOURS);<\/p>\n<p>        \/\/ 9. \u3010\u6a21\u62df\u3011\u8c03\u7528\u77ed\u4fe1\u5e73\u53f0&#xff08;\u5b9e\u9645\u66ff\u6362\u4e3a\u963f\u91cc\u4e91\/\u817e\u8baf\u4e91 SDK&#xff09;<br \/>\n        System.out.println(&#034;\u3010\u6d4b\u8bd5\u3011\u5411 &#034; &#043; phone &#043; &#034; \u53d1\u9001\u9a8c\u8bc1\u7801: &#034; &#043; code);<\/p>\n<p>        return ResponseEntity.ok(&#034;\u9a8c\u8bc1\u7801\u5df2\u53d1\u9001&#xff0c;\u8bf7\u6ce8\u610f\u67e5\u6536&#034;);<br \/>\n    }<\/p>\n<p>    \/\/ \u8f85\u52a9\u65b9\u6cd5&#xff1a;\u83b7\u53d6 Redis \u4e2d\u7684\u8ba1\u6570\u503c<br \/>\n    private Integer getRedisCount(String key, int expireSeconds) {<br \/>\n        String val &#061; redisTemplate.opsForValue().get(key);<br \/>\n        if (val &#061;&#061; null) {<br \/>\n            redisTemplate.opsForValue().set(key, &#034;0&#034;, expireSeconds, TimeUnit.SECONDS);<br \/>\n            return 0;<br \/>\n        }<br \/>\n        return Integer.parseInt(val);<br \/>\n    }<\/p>\n<p>    \/\/ \u8f85\u52a9\u65b9\u6cd5&#xff1a;\u83b7\u53d6\u5ba2\u6237\u7aef\u771f\u5b9e IP<br \/>\n    private String getClientIP(HttpServletRequest request) {<br \/>\n        String ip &#061; request.getHeader(&#034;X-Forwarded-For&#034;);<br \/>\n        if (ip &#061;&#061; null || ip.isEmpty() || &#034;unknown&#034;.equalsIgnoreCase(ip)) {<br \/>\n            ip &#061; request.getHeader(&#034;X-Real-IP&#034;);<br \/>\n        }<br \/>\n        if (ip &#061;&#061; null || ip.isEmpty() || &#034;unknown&#034;.equalsIgnoreCase(ip)) {<br \/>\n            ip &#061; request.getRemoteAddr();<br \/>\n        }<br \/>\n        return ip;<br \/>\n    }<\/p>\n<p>    \/\/ \u624b\u673a\u53f7\u6b63\u5219\u6821\u9a8c<br \/>\n    private boolean isValidPhone(String phone) {<br \/>\n        return phone.matches(&#034;^1[3-9]\\\\\\\\d{9}$&#034;);<br \/>\n    }<br \/>\n}<\/p>\n<hr \/>\n<h4>5. \u9a8c\u8bc1\u7801\u6821\u9a8c\u63a5\u53e3&#xff08;\u7528\u4e8e\u6ce8\u518c\/\u767b\u5f55&#xff09;<\/h4>\n<p>&#064;PostMapping(&#034;\/verify-code&#034;)<br \/>\npublic ResponseEntity&lt;String&gt; verifyCode(&#064;RequestParam String phone,<br \/>\n                                         &#064;RequestParam String inputCode) {<br \/>\n    String realCode &#061; redisTemplate.opsForValue().get(SMS_CODE_KEY_PREFIX &#043; phone);<\/p>\n<p>    if (realCode &#061;&#061; null) {<br \/>\n        return ResponseEntity.badRequest().body(&#034;\u9a8c\u8bc1\u7801\u5df2\u8fc7\u671f&#034;);<br \/>\n    }<\/p>\n<p>    if (!realCode.equals(inputCode)) {<br \/>\n        return ResponseEntity.badRequest().body(&#034;\u9a8c\u8bc1\u7801\u9519\u8bef&#034;);<br \/>\n    }<\/p>\n<p>    \/\/ \u9a8c\u8bc1\u6210\u529f&#xff01;\u5220\u9664\u9a8c\u8bc1\u7801&#xff08;\u4e00\u6b21\u6027\u4f7f\u7528&#xff09;<br \/>\n    redisTemplate.delete(SMS_CODE_KEY_PREFIX &#043; phone);<\/p>\n<p>    \/\/ TODO: \u6267\u884c\u6ce8\u518c\/\u767b\u5f55\u903b\u8f91<\/p>\n<p>    return ResponseEntity.ok(&#034;\u9a8c\u8bc1\u6210\u529f&#034;);<br \/>\n}<\/p>\n<p>\u2705\u00a0\u5173\u952e\u70b9&#xff1a;\u9a8c\u8bc1\u6210\u529f\u540e\u7acb\u5373\u5220\u9664\u9a8c\u8bc1\u7801&#xff0c;\u9632\u6b62\u91cd\u590d\u4f7f\u7528&#xff01;<\/p>\n<hr \/>\n<h3>\u4e94\u3001\u5b89\u5168\u52a0\u56fa\u63aa\u65bd\u603b\u7ed3<\/h3>\n<table>\n<tr>\u98ce\u9669\u9632\u5fa1\u65b9\u6848<\/tr>\n<tbody>\n<tr>\n<td>\u673a\u5668\u5237\u9a8c\u8bc1\u7801<\/td>\n<td>\u524d\u7f6e\u56fe\u5f62\u9a8c\u8bc1\u7801&#xff08;\u6216\u884c\u4e3a\u9a8c\u8bc1&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u5355\u624b\u673a\u53f7\u72c2\u70b9<\/td>\n<td>60\u79d2\u5185\u96501\u6b21&#xff08;Redis &#043; TTL&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>IP \u6279\u91cf\u6ce8\u518c<\/td>\n<td>IP \u65e5\u9650\u989d&#xff08;\u598220\u6b21\/\u5929&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u9a8c\u8bc1\u7801\u7206\u7834<\/td>\n<td>5\u5206\u949f\u8fc7\u671f &#043; \u4e00\u6b21\u6027\u4f7f\u7528<\/td>\n<\/tr>\n<tr>\n<td>\u77ed\u4fe1\u8d39\u7528\u5931\u63a7<\/td>\n<td>\u76d1\u63a7\u544a\u8b66 &#043; \u7b2c\u4e09\u65b9\u5e73\u53f0\u989d\u5ea6\u9650\u5236<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#x1f4a1;\u00a0\u8fdb\u9636\u5efa\u8bae&#xff1a;<\/p>\n<ul>\n<li>\u654f\u611f\u64cd\u4f5c&#xff08;\u5982\u6539\u5bc6&#xff09;\u589e\u52a0\u4e8c\u6b21\u9a8c\u8bc1<\/li>\n<li>\u4f7f\u7528\u963f\u91cc\u4e91\u201c\u98ce\u9669\u8bc6\u522b\u201d\u670d\u52a1\u68c0\u6d4b\u9ed1\u4ea7 IP<\/li>\n<li>\u9a8c\u8bc1\u7801\u957f\u5ea6\u53ef\u52a8\u6001\u8c03\u6574&#xff08;\u5982 6&#xff5e;8 \u4f4d&#xff09;<\/li>\n<\/ul>\n<hr \/>\n<h3>\u516d\u3001\u5e38\u89c1\u95ee\u9898\u4e0e\u907f\u5751\u6307\u5357<\/h3>\n<h4>\u274c \u5751 1&#xff1a;\u9a8c\u8bc1\u7801\u5b58 Session<\/h4>\n<p>\u95ee\u9898&#xff1a;\u96c6\u7fa4\u90e8\u7f72\u65f6 Session \u4e0d\u5171\u4eab<br \/>\n\u89e3\u51b3&#xff1a;\u5fc5\u987b\u7528 Redis \u5b58\u50a8<\/p>\n<h4>\u274c \u5751 2&#xff1a;\u53ea\u9650\u5236\u624b\u673a\u53f7&#xff0c;\u4e0d\u9650 IP<\/h4>\n<p>\u540e\u679c&#xff1a;\u9ed1\u4ea7\u6362\u53f7\u72c2\u5237<br \/>\n\u89e3\u51b3&#xff1a;IP &#043; \u624b\u673a\u53f7 \u53cc\u7ef4\u5ea6\u9650\u6d41<\/p>\n<h4>\u274c \u5751 3&#xff1a;\u9a8c\u8bc1\u7801\u53ef\u91cd\u590d\u4f7f\u7528<\/h4>\n<p>\u98ce\u9669&#xff1a;\u4e2d\u95f4\u4eba\u653b\u51fb\u91cd\u653e<br \/>\n\u89e3\u51b3&#xff1a;\u9a8c\u8bc1\u540e\u7acb\u5373\u5220\u9664<\/p>\n<h4>\u274c \u5751 4&#xff1a;\u672a\u6821\u9a8c\u624b\u673a\u53f7\u683c\u5f0f<\/h4>\n<p>\u540e\u679c&#xff1a;Redis \u88ab\u6076\u610f Key \u5360\u6ee1<br \/>\n\u89e3\u51b3&#xff1a;\u4e25\u683c\u6b63\u5219\u6821\u9a8c<\/p>\n<hr \/>\n<h3>\u4e03\u3001\u7ed3\u8bed<\/h3>\n<p>\u611f\u8c22\u60a8\u7684\u9605\u8bfb&#xff01;\u5982\u679c\u4f60\u6709\u4efb\u4f55\u7591\u95ee\u6216\u60f3\u8981\u5206\u4eab\u7684\u7ecf\u9a8c&#xff0c;\u8bf7\u5728\u8bc4\u8bba\u533a\u7559\u8a00\u4ea4\u6d41&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u524d\u8a00&#xff1a;\u77ed\u4fe1\u9a8c\u8bc1\u7801 \u2260 \u8c03\u4e2a\u63a5\u53e3\u90a3\u4e48\u7b80\u5355&#xff01;\u5f88\u591a\u5f00\u53d1\u8005\u8ba4\u4e3a&#xff1a;\u201c\u53d1\u77ed\u4fe1\u9a8c\u8bc1\u7801\u4e0d\u5c31\u662f\u8c03\u4e2a\u7b2c\u4e09\u65b9 API \u5417&#xff1f;\u201d<br \/>\n\u4f46\u771f\u5b9e\u751f\u4ea7\u73af\u5883\u4e2d&#xff0c;\u4f60\u5fc5\u987b\u8003\u8651&#xff1a;\u274c \u7528\u6237\u75af\u72c2\u70b9\u51fb\u201c\u83b7\u53d6\u9a8c\u8bc1\u7801\u201d&#xff0c;\u5bfc\u81f4\u77ed\u4fe1\u8d39\u7528\u98d9\u5347\u274c \u9ed1\u4ea7\u7528\u811a\u672c\u6279\u91cf\u6ce8\u518c&#xff0c;\u6d88\u8017\u7cfb\u7edf\u8d44\u6e90\u274c \u9a8c\u8bc1\u7801\u88ab\u66b4\u529b\u7834\u89e3&#xff0c;\u8d26\u53f7\u88ab\u76d7\u274c \u540c\u4e00\u624b\u673a\u53f7\u9891\u7e41\u8bf7\u6c42&#xff0c;\u5f71\u54cd\u6b63\u5e38\u7528\u6237\u4e00\u4e2a\u5065\u58ee\u7684\u77ed\u4fe1\u9a8c\u8bc1\u7801\u529f\u80fd&#xff0c;\u6838\u5fc3\u4e0d\u5728\u201c\u53d1<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[105,398],"topic":[],"class_list":["post-64210","post","type-post","status-publish","format-standard","hentry","category-server","tag-redis","tag-398"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5b9e\u73b0\u53d1\u9001\u77ed\u4fe1\u9a8c\u8bc1\u7801\u529f\u80fd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/64210.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5b9e\u73b0\u53d1\u9001\u77ed\u4fe1\u9a8c\u8bc1\u7801\u529f\u80fd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001\u524d\u8a00&#xff1a;\u77ed\u4fe1\u9a8c\u8bc1\u7801 \u2260 \u8c03\u4e2a\u63a5\u53e3\u90a3\u4e48\u7b80\u5355&#xff01;\u5f88\u591a\u5f00\u53d1\u8005\u8ba4\u4e3a&#xff1a;\u201c\u53d1\u77ed\u4fe1\u9a8c\u8bc1\u7801\u4e0d\u5c31\u662f\u8c03\u4e2a\u7b2c\u4e09\u65b9 API \u5417&#xff1f;\u201d \u4f46\u771f\u5b9e\u751f\u4ea7\u73af\u5883\u4e2d&#xff0c;\u4f60\u5fc5\u987b\u8003\u8651&#xff1a;\u274c \u7528\u6237\u75af\u72c2\u70b9\u51fb\u201c\u83b7\u53d6\u9a8c\u8bc1\u7801\u201d&#xff0c;\u5bfc\u81f4\u77ed\u4fe1\u8d39\u7528\u98d9\u5347\u274c \u9ed1\u4ea7\u7528\u811a\u672c\u6279\u91cf\u6ce8\u518c&#xff0c;\u6d88\u8017\u7cfb\u7edf\u8d44\u6e90\u274c \u9a8c\u8bc1\u7801\u88ab\u66b4\u529b\u7834\u89e3&#xff0c;\u8d26\u53f7\u88ab\u76d7\u274c \u540c\u4e00\u624b\u673a\u53f7\u9891\u7e41\u8bf7\u6c42&#xff0c;\u5f71\u54cd\u6b63\u5e38\u7528\u6237\u4e00\u4e2a\u5065\u58ee\u7684\u77ed\u4fe1\u9a8c\u8bc1\u7801\u529f\u80fd&#xff0c;\u6838\u5fc3\u4e0d\u5728\u201c\u53d1\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/64210.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-22T16:48:28+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/64210.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/64210.html\",\"name\":\"\u5b9e\u73b0\u53d1\u9001\u77ed\u4fe1\u9a8c\u8bc1\u7801\u529f\u80fd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-22T16:48:28+00:00\",\"dateModified\":\"2026-01-22T16:48:28+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/64210.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/64210.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/64210.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5b9e\u73b0\u53d1\u9001\u77ed\u4fe1\u9a8c\u8bc1\u7801\u529f\u80fd\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u5b9e\u73b0\u53d1\u9001\u77ed\u4fe1\u9a8c\u8bc1\u7801\u529f\u80fd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/64210.html","og_locale":"zh_CN","og_type":"article","og_title":"\u5b9e\u73b0\u53d1\u9001\u77ed\u4fe1\u9a8c\u8bc1\u7801\u529f\u80fd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001\u524d\u8a00&#xff1a;\u77ed\u4fe1\u9a8c\u8bc1\u7801 \u2260 \u8c03\u4e2a\u63a5\u53e3\u90a3\u4e48\u7b80\u5355&#xff01;\u5f88\u591a\u5f00\u53d1\u8005\u8ba4\u4e3a&#xff1a;\u201c\u53d1\u77ed\u4fe1\u9a8c\u8bc1\u7801\u4e0d\u5c31\u662f\u8c03\u4e2a\u7b2c\u4e09\u65b9 API \u5417&#xff1f;\u201d \u4f46\u771f\u5b9e\u751f\u4ea7\u73af\u5883\u4e2d&#xff0c;\u4f60\u5fc5\u987b\u8003\u8651&#xff1a;\u274c \u7528\u6237\u75af\u72c2\u70b9\u51fb\u201c\u83b7\u53d6\u9a8c\u8bc1\u7801\u201d&#xff0c;\u5bfc\u81f4\u77ed\u4fe1\u8d39\u7528\u98d9\u5347\u274c \u9ed1\u4ea7\u7528\u811a\u672c\u6279\u91cf\u6ce8\u518c&#xff0c;\u6d88\u8017\u7cfb\u7edf\u8d44\u6e90\u274c \u9a8c\u8bc1\u7801\u88ab\u66b4\u529b\u7834\u89e3&#xff0c;\u8d26\u53f7\u88ab\u76d7\u274c \u540c\u4e00\u624b\u673a\u53f7\u9891\u7e41\u8bf7\u6c42&#xff0c;\u5f71\u54cd\u6b63\u5e38\u7528\u6237\u4e00\u4e2a\u5065\u58ee\u7684\u77ed\u4fe1\u9a8c\u8bc1\u7801\u529f\u80fd&#xff0c;\u6838\u5fc3\u4e0d\u5728\u201c\u53d1","og_url":"https:\/\/www.wsisp.com\/helps\/64210.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-22T16:48:28+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/64210.html","url":"https:\/\/www.wsisp.com\/helps\/64210.html","name":"\u5b9e\u73b0\u53d1\u9001\u77ed\u4fe1\u9a8c\u8bc1\u7801\u529f\u80fd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-22T16:48:28+00:00","dateModified":"2026-01-22T16:48:28+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/64210.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/64210.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/64210.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u5b9e\u73b0\u53d1\u9001\u77ed\u4fe1\u9a8c\u8bc1\u7801\u529f\u80fd"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/64210","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=64210"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/64210\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=64210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=64210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=64210"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=64210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}