{"id":23847,"date":"2025-04-19T08:42:11","date_gmt":"2025-04-19T00:42:11","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/23847.html"},"modified":"2025-04-19T08:42:11","modified_gmt":"2025-04-19T00:42:11","slug":"%e5%9f%ba%e4%ba%8eredisaoplua%e8%84%9a%e6%9c%ac%e5%ae%9e%e7%8e%b0%e4%b8%80%e4%b8%aa%e6%9c%8d%e5%8a%a1%e5%99%a8%e9%99%90%e6%b5%81%e6%9c%ba%e5%88%b6","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/23847.html","title":{"rendered":"\u57fa\u4e8eRedis+AOP+Lua\u811a\u672c\u5b9e\u73b0\u4e00\u4e2a\u670d\u52a1\u5668\u9650\u6d41\u673a\u5236"},"content":{"rendered":"<p>\u540e\u7aef\u67d0\u4e9b\u63a5\u53e3\u5728\u9ad8\u5e76\u53d1\u7684\u538b\u529b\u4e0b\u5f80\u5f80\u4f1a\u5bfc\u81f4\u6027\u80fd\u7684\u4e25\u91cd\u4e0b\u964d&#xff0c;\u4e3a\u4e86\u7ef4\u6301\u6211\u4eec\u540e\u7aef\u670d\u52a1\u578b\u7684\u9ad8\u6027\u80fd\u548c\u9ad8\u53ef\u7528&#xff0c;\u6211\u4eec\u5f80\u5f80\u53ef\u4ee5\u5bf9\u67d0\u4e9b\u63a5\u53e3\u6216\u67d0\u4e9b\u7528\u6237\u53bb\u8bbe\u8ba1\u9650\u6d41\u673a\u5236&#xff0c;\u63a7\u5236\u8fd9\u4e9b\u70ed\u70b9\u63a5\u53e3\u7684\u8bbf\u95ee\u91cf&#xff0c;\u6211\u8fd9\u91cc\u5229\u7528Redis\u7684\u9ad8\u6027\u80fd\u4f18\u52bf&#xff0c;\u5e76\u6574\u5408AOP\u7f16\u7a0b\u548c\u5f15\u5165Lua\u9650\u6d41\u811a\u672c\u5728SpringBoot\u4e2d\u5bf9\u4efb\u610f\u63a5\u53e3\u6216\u67d0\u4e9b\u7528\u6237\u5b9e\u73b0\u4e86\u8bbf\u95ee\u91cf\u9650\u6d41\u7684\u673a\u5236&#xff0c;\u5176\u4e2d&#xff0c;\u6211\u8fd9\u91cc\u7ed9\u51fa\u4e86\u4e09\u79cd\u9650\u6d41\u673a\u5236&#xff1a;\u7528\u6237&#xff0c;IP\u5730\u5740&#xff0c;\u5168\u5c40\u9650\u6d41<\/p>\n<h2>1.\u5b9a\u4e49\u9650\u6d41\u65b9\u5f0f<\/h2>\n<p>  \/**<br \/>\n * \u9650\u6d41\u7c7b\u578b<br \/>\n * &#064;Author GuihaoLv<br \/>\n *\/<br \/>\npublic enum LimitType {<br \/>\n    \/**<br \/>\n     * \u9ed8\u8ba4\u7b56\u7565\u5168\u5c40\u9650\u6d41<br \/>\n     *\/<br \/>\n    DEFAULT,<\/p>\n<p>    \/**<br \/>\n     * \u6839\u636e\u8bf7\u6c42\u8005IP\u8fdb\u884c\u9650\u6d41<br \/>\n     *\/<br \/>\n    IP,<\/p>\n<p>    \/**<br \/>\n     * \u6839\u636e\u8bf7\u6c42\u8005\u7684\u7528\u6237ID\u8fdb\u884c\u9650\u6d41<br \/>\n     *\/<br \/>\n    USER,<\/p>\n<p>    \/**<br \/>\n     * \u6839\u636e\u8bf7\u6c42\u8005\u7684\u90e8\u95e8\u8fdb\u884c\u9650\u6d41<br \/>\n     *\/<br \/>\n    DEPT,<br \/>\n}<\/p>\n<h2>2.\u5f15\u5165AOP&#xff0c;\u81ea\u5b9a\u4e49\u9650\u6d41\u6ce8\u89e3\u548c\u9650\u6d41\u5904\u7406\u7684\u5207\u9762\u7c7b<\/h2>\n<p> \/**<br \/>\n * \u9650\u6d41\u6ce8\u89e3<br \/>\n * &#064;Author GuihaoLv<br \/>\n *\/<br \/>\n\/\/\u5b9e\u4f8b &#064;RateLimiter(time &#061; 60, count &#061; 5, limitType &#061; LimitType.IP) \u6548\u679c&#xff1a;\u540c\u4e00IP 60\u79d2\u5185\u6700\u591a\u5141\u8bb85\u6b21\u767b\u5f55\u5c1d\u8bd5\u3002<br \/>\n&#064;Target(ElementType.METHOD) \/\/\u8868\u793a\u8be5\u6ce8\u89e3\u4ec5\u80fd\u6807\u6ce8\u5728\u65b9\u6cd5\u4e0a&#xff0c;\u7528\u4e8e\u5bf9\u5177\u4f53\u65b9\u6cd5\u8fdb\u884c\u9650\u6d41\u63a7\u5236\u3002<br \/>\n&#064;Retention(RetentionPolicy.RUNTIME) \/\/\u6ce8\u89e3\u5728\u8fd0\u884c\u65f6\u4fdd\u7559&#xff0c;\u53ef\u901a\u8fc7\u53cd\u5c04\u673a\u5236\u8bfb\u53d6\u6ce8\u89e3\u4fe1\u606f&#xff0c;\u5b9e\u73b0\u52a8\u6001\u9650\u6d41\u903b\u8f91\u3002<br \/>\n&#064;Documented \/\/\u6ce8\u89e3\u4fe1\u606f\u4f1a\u5305\u542b\u5728\u751f\u6210\u7684 JavaDoc \u4e2d<br \/>\npublic &#064;interface RateLimiter {<br \/>\n    \/**<br \/>\n     * \u9650\u6d41key<br \/>\n     *\/<br \/>\n    public String key() default RedisConstant.RATE_LIMIT_KEY;<br \/>\n    \/**<br \/>\n     * \u9650\u6d41\u65f6\u95f4,\u5355\u4f4d\u79d2<br \/>\n     *\/<br \/>\n    public int time() default 60;<\/p>\n<p>    \/**<br \/>\n     * \u9650\u6d41\u6b21\u6570<br \/>\n     *\/<br \/>\n    public int count() default 100;<\/p>\n<p>     \/**<br \/>\n     * \u9650\u6d41\u7c7b\u578b<br \/>\n     *\/<br \/>\n    public LimitType limitType() default LimitType.DEFAULT;<br \/>\n}<\/p>\n<p> \/**<br \/>\n * \u9650\u6d41\u5904\u7406\u5207\u9762<br \/>\n * &#064;Author GuihaoLv<br \/>\n *\/<br \/>\n&#064;Aspect<br \/>\n&#064;Component<br \/>\n\/\/\u786e\u4fdd\u4ec5\u5f53\u914d\u7f6e\u9879 spring.cache.type&#061;redis \u65f6&#xff0c;\u5207\u9762\u624d\u4f1a\u751f\u6548<br \/>\n&#064;ConditionalOnProperty(prefix &#061; &#034;spring.cache&#034;, name &#061; { &#034;type&#034; }, havingValue &#061; &#034;redis&#034;, matchIfMissing &#061; false)<br \/>\npublic class RateLimiterAspect<br \/>\n{<br \/>\n    private static final Logger log &#061; LoggerFactory.getLogger(RateLimiterAspect.class);<\/p>\n<p>    private RedisTemplate&lt;Object, Object&gt; redisTemplate; \/\/redis \u64cd\u4f5c\u6a21\u677f&#xff0c;\u7528\u4e8e\u6267\u884c Lua \u811a\u672c\u548c Redis \u547d\u4ee4<\/p>\n<p>    private RedisScript&lt;Long&gt; limitScript; \/\/\u9650\u6d41\u6838\u5fc3\u903b\u8f91\u7684 Lua \u811a\u672c<\/p>\n<p>    &#064;Autowired<br \/>\n    public void setRedisTemplate1(RedisTemplate&lt;Object, Object&gt; redisTemplate)<br \/>\n    {<br \/>\n        this.redisTemplate &#061; redisTemplate;<br \/>\n    }<\/p>\n<p>    &#064;Autowired<br \/>\n    public void setLimitScript(RedisScript&lt;Long&gt; limitScript)<br \/>\n    {<br \/>\n        this.limitScript &#061; limitScript;<br \/>\n    }<br \/>\n    &#064;Autowired<br \/>\n    private ObjectMapper jacksonObjectMapper;<\/p>\n<p>    &#064;Before(&#034;&#064;annotation(rateLimiter)&#034;)<br \/>\n    public void doBefore(JoinPoint point, RateLimiter rateLimiter) throws Throwable<br \/>\n    {<br \/>\n        \/\/1. \u83b7\u53d6\u6ce8\u89e3\u53c2\u6570<br \/>\n        int time &#061; rateLimiter.time(); \/\/\u65f6\u95f4\u7a97\u53e3&#xff08;\u79d2&#xff09;<br \/>\n        int count &#061; rateLimiter.count();\/\/ \u5141\u8bb8\u7684\u8bf7\u6c42\u6b21\u6570<\/p>\n<p>        \/\/2. \u751f\u6210\u552f\u4e00\u9650\u6d41 Key<br \/>\n        String combineKey &#061; getCombineKey(rateLimiter, point);<br \/>\n        List&lt;Object&gt; keys &#061; Collections.singletonList(combineKey);<br \/>\n        try<br \/>\n        {<br \/>\n            \/\/3. \u4ee5key\u4e3a\u53c2\u6570\u6267\u884c Lua \u811a\u672c&#xff08;\u539f\u5b50\u6027\u64cd\u4f5c&#xff09; keys:Redis \u5b58\u50a8\u7684 Key<br \/>\n            \/\/Lua\u811a\u672c\u4f1a\u68c0\u67e5Key\u662f\u5426\u5b58\u5728&#xff0c;\u5982\u679c\u4e0d\u5b58\u5728\u5219\u521b\u5efa\u5e76\u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4&#xff0c;\u5982\u679c\u5b58\u5728\u5219\u9012\u589e\u8ba1\u6570\u5668\u3002<br \/>\n            Long number &#061; redisTemplate.execute(limitScript, keys, count, time);<br \/>\n            if (StringUtils.isEmpty(number) || number.intValue() &gt; count)<br \/>\n            {<br \/>\n                throw new Exception(&#034;\u8bbf\u95ee\u8fc7\u4e8e\u9891\u7e41&#xff0c;\u8bf7\u7a0d\u5019\u518d\u8bd5&#034;);<br \/>\n            }<br \/>\n            log.info(&#034;\u9650\u5236\u8bf7\u6c42&#039;{}&#039;,\u5f53\u524d\u8bf7\u6c42&#039;{}&#039;,\u7f13\u5b58key&#039;{}&#039;&#034;, count, number.intValue(), combineKey);<br \/>\n        } catch (RuntimeException e)<br \/>\n        {<br \/>\n            throw new RuntimeException(&#034;\u670d\u52a1\u5668\u9650\u6d41\u5f02\u5e38&#xff0c;\u8bf7\u7a0d\u5019\u518d\u8bd5&#034;);<br \/>\n        } catch (Exception e)<br \/>\n        {<br \/>\n            throw e;<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/IP &#043; \u7c7b\u540d &#043; \u65b9\u6cd5\u540d \u7684\u62fc\u63a5\u65b9\u5f0f&#xff0c;\u786e\u4fdd\u4e0d\u540c\u573a\u666f\u7684Key\u4e0d\u51b2\u7a81\u3002<br \/>\n    \/\/Key\u7ed3\u6784\u6e05\u6670&#xff0c;\u4fbf\u4e8e\u8c03\u8bd5\u548c\u76d1\u63a7&#xff08;\u5982\u901a\u8fc7Redis\u76f4\u63a5\u67e5\u770b\u8ba1\u6570\u5668&#xff09;\u3002<br \/>\n    public String getCombineKey(RateLimiter rateLimiter, JoinPoint point)<br \/>\n    {<br \/>\n        StringBuffer stringBuffer &#061; new StringBuffer(rateLimiter.key());<\/p>\n<p>        switch (rateLimiter.limitType()) {<br \/>\n            case IP:<br \/>\n                try {<br \/>\n                    limitByIp(stringBuffer);<br \/>\n                } catch (IOException e) {<br \/>\n                    e.printStackTrace();<br \/>\n                } catch (InterruptedException e) {<br \/>\n                    e.printStackTrace();<br \/>\n                }<br \/>\n                break;<br \/>\n            case USER:<br \/>\n                limitByUser(stringBuffer);<br \/>\n                break;<br \/>\n            case DEFAULT:<br \/>\n                limitByDefault(stringBuffer,point);<br \/>\n                break;<br \/>\n        }<\/p>\n<p>           return stringBuffer.toString();<br \/>\n    }<\/p>\n<p>     \/**<br \/>\n     * \u6309IP\u9650\u6d41<br \/>\n     * &#064;param stringBuffer<br \/>\n     *\/<br \/>\n    private final HttpClient httpClient &#061; HttpClient.newHttpClient();<br \/>\n    private void limitByIp(StringBuffer stringBuffer) throws IOException, InterruptedException {<br \/>\n        String[] services &#061; {<br \/>\n                &#034;https:\/\/api.ipify.org&#034;,<br \/>\n                &#034;https:\/\/icanhazip.com&#034;<br \/>\n        };<br \/>\n        for (String serviceUrl : services) {<br \/>\n                HttpRequest request &#061; HttpRequest.newBuilder()<br \/>\n                        .uri(URI.create(serviceUrl))<br \/>\n                        .GET()<br \/>\n                        .build();<br \/>\n                HttpResponse&lt;String&gt; response &#061; httpClient.send(request, HttpResponse.BodyHandlers.ofString());<br \/>\n                String ip &#061; response.body().trim();<br \/>\n                stringBuffer.append(&#034;:ip:&#034;).append(ip);<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * \u5168\u5c40\u9650\u6d41<br \/>\n     * &#064;param stringBuffer<br \/>\n     * &#064;param point<br \/>\n     *\/<br \/>\n    private void limitByDefault(StringBuffer stringBuffer, JoinPoint point) {<br \/>\n        \/\/\u6309\u65b9\u6cd5\u9650\u6d41&#xff1a;\u62fc\u63a5\u7c7b\u540d &#043; \u65b9\u6cd5\u540d<br \/>\n        MethodSignature signature &#061; (MethodSignature) point.getSignature();<br \/>\n        Method method &#061; signature.getMethod();<br \/>\n        Class&lt;?&gt; targetClass &#061; method.getDeclaringClass();<br \/>\n        stringBuffer.append(targetClass.getName()).append(&#034;-&#034;).append(method.getName());<\/p>\n<p>    }<\/p>\n<p>    \/**<br \/>\n     * \u6309\u7528\u6237\u9650\u6d41<br \/>\n     * &#064;param stringBuffer<br \/>\n     *\/<br \/>\n    private void limitByUser(StringBuffer stringBuffer) {<br \/>\n            \/\/\u83b7\u53d6\u5f53\u524d\u7528\u6237<br \/>\n            String userSubject &#061; UserThreadLocal.getSubject();<br \/>\n            User user&#061;new User();<br \/>\n            try {<br \/>\n                user &#061; jacksonObjectMapper.readValue(userSubject, User.class);<br \/>\n            } catch (JsonProcessingException e) {<br \/>\n                throw new RuntimeException(&#034;\u65e0\u6cd5\u83b7\u53d6\u5f53\u524d\u7528\u6237&#034;);<br \/>\n            }<br \/>\n            stringBuffer.append(&#034;:user:&#034;).append(user.getId());<br \/>\n    }<\/p>\n<p>} <\/p>\n<h2>3. \u5728Redis\u7684\u914d\u7f6e\u7c7b\u4e2d\u6574\u5408Lua\u8bed\u8a00\u81ea\u5b9a\u4e49\u9650\u6d41\u811a\u672c\u7684\u6267\u884c<\/h2>\n<p> \/**<br \/>\n * \u9650\u6d41\u811a\u672c\u5b9a\u4e49<br \/>\n * &#064;return<br \/>\n *\/<br \/>\n&#064;Bean<br \/>\npublic DefaultRedisScript&lt;Long&gt; limitScript() {<br \/>\n    DefaultRedisScript&lt;Long&gt; redisScript &#061; new DefaultRedisScript&lt;&gt;();<br \/>\n    redisScript.setScriptText(limitScriptText()); \/\/\u52a0\u8f7dLua\u811a\u672c<br \/>\n    redisScript.setResultType(Long.class); \/\/ \u8fd4\u56de\u7c7b\u578b\u4e3aLong<br \/>\n    return redisScript;<br \/>\n}<\/p>\n<p>\/**<br \/>\n * \u9650\u6d41\u811a\u672c<br \/>\n *\/<br \/>\nprivate String limitScriptText() {<br \/>\n    return &#034;local key &#061; KEYS[1]\\\\n&#034; &#043;<br \/>\n            &#034;local count &#061; tonumber(ARGV[1])\\\\n&#034; &#043;<br \/>\n            &#034;local time &#061; tonumber(ARGV[2])\\\\n&#034; &#043;<br \/>\n            &#034;local current &#061; redis.call(&#039;get&#039;, key);\\\\n&#034; &#043;<br \/>\n            &#034;if current and tonumber(current) &gt; count then\\\\n&#034; &#043;<br \/>\n            &#034;    return tonumber(current);\\\\n&#034; &#043;<br \/>\n            &#034;end\\\\n&#034; &#043;<br \/>\n            &#034;current &#061; redis.call(&#039;incr&#039;, key)\\\\n&#034; &#043;<br \/>\n            &#034;if tonumber(current) &#061;&#061; 1 then\\\\n&#034; &#043;<br \/>\n            &#034;    redis.call(&#039;expire&#039;, key, time)\\\\n&#034; &#043;<br \/>\n            &#034;end\\\\n&#034; &#043;<br \/>\n            &#034;return tonumber(current);&#034;;<br \/>\n} <\/p>\n<h2>4. \u9650\u6d41\u6ce8\u89e3\u7684\u4f7f\u7528<\/h2>\n<\/p>\n<h5>\u6848\u4f8b1&#xff1a;\u767b\u5f55\u63a5\u53e3IP\u9650\u6d41<\/h5>\n<p> &#064;RateLimiter( key &#061; &#034;login_attempt&#034;, time &#061; 300, \/\/ 5\u5206\u949f count &#061; 5,<br \/>\nlimitType &#061; LimitType.IP )<br \/>\n&#064;PostMapping(&#034;\/login&#034;)<br \/>\npublic Response login(&#064;RequestBody LoginDTO dto) { \/\/ \u767b\u5f55\u903b\u8f91 }<\/p>\n<h5>\u6848\u4f8b2&#xff1a;API\u7528\u6237\u7ef4\u5ea6\u9650\u6d41<\/h5>\n<p>&#064;RateLimiter( key &#061; &#034;api_v1:data_export&#034;, time &#061; 3600, \/\/ 1\u5c0f\u65f6 count &#061; 10,<\/p>\n<p>limitType &#061; LimitType.USER )<\/p>\n<p>&#064;GetMapping(&#034;\/export&#034;)<\/p>\n<p>public void exportData() { \/\/ \u6570\u636e\u5bfc\u51fa\u903b\u8f91 }<\/p>\n<p>\u8fd9\u6837\u5c31\u80fd\u5bf9\u4e0a\u8ff0\u63a5\u53e3\u5b9e\u73b0\u5bf9\u5e94\u7684\u9650\u6d41\u673a\u5236\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb868\u6b21\uff0c\u70b9\u8d5e15\u6b21\uff0c\u6536\u85cf13\u6b21\u3002\u57fa\u4e8eRedis+AOP+Lua\u811a\u672c\u5b9e\u73b0\u4e00\u4e2a\u670d\u52a1\u5668\u9650\u6d41\u673a\u5236 _lua\u9650\u6d41\u811a\u672c<\/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":[99,105,98],"topic":[],"class_list":["post-23847","post","type-post","status-publish","format-standard","hentry","category-server","tag-java","tag-redis","tag-spring-boot"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u57fa\u4e8eRedis+AOP+Lua\u811a\u672c\u5b9e\u73b0\u4e00\u4e2a\u670d\u52a1\u5668\u9650\u6d41\u673a\u5236 - \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\/23847.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u57fa\u4e8eRedis+AOP+Lua\u811a\u672c\u5b9e\u73b0\u4e00\u4e2a\u670d\u52a1\u5668\u9650\u6d41\u673a\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb868\u6b21\uff0c\u70b9\u8d5e15\u6b21\uff0c\u6536\u85cf13\u6b21\u3002\u57fa\u4e8eRedis+AOP+Lua\u811a\u672c\u5b9e\u73b0\u4e00\u4e2a\u670d\u52a1\u5668\u9650\u6d41\u673a\u5236 _lua\u9650\u6d41\u811a\u672c\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/23847.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-19T00:42:11+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\/23847.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/23847.html\",\"name\":\"\u57fa\u4e8eRedis+AOP+Lua\u811a\u672c\u5b9e\u73b0\u4e00\u4e2a\u670d\u52a1\u5668\u9650\u6d41\u673a\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-19T00:42:11+00:00\",\"dateModified\":\"2025-04-19T00:42:11+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/23847.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/23847.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/23847.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u57fa\u4e8eRedis+AOP+Lua\u811a\u672c\u5b9e\u73b0\u4e00\u4e2a\u670d\u52a1\u5668\u9650\u6d41\u673a\u5236\"}]},{\"@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":"\u57fa\u4e8eRedis+AOP+Lua\u811a\u672c\u5b9e\u73b0\u4e00\u4e2a\u670d\u52a1\u5668\u9650\u6d41\u673a\u5236 - \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\/23847.html","og_locale":"zh_CN","og_type":"article","og_title":"\u57fa\u4e8eRedis+AOP+Lua\u811a\u672c\u5b9e\u73b0\u4e00\u4e2a\u670d\u52a1\u5668\u9650\u6d41\u673a\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb868\u6b21\uff0c\u70b9\u8d5e15\u6b21\uff0c\u6536\u85cf13\u6b21\u3002\u57fa\u4e8eRedis+AOP+Lua\u811a\u672c\u5b9e\u73b0\u4e00\u4e2a\u670d\u52a1\u5668\u9650\u6d41\u673a\u5236 _lua\u9650\u6d41\u811a\u672c","og_url":"https:\/\/www.wsisp.com\/helps\/23847.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-19T00:42:11+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\/23847.html","url":"https:\/\/www.wsisp.com\/helps\/23847.html","name":"\u57fa\u4e8eRedis+AOP+Lua\u811a\u672c\u5b9e\u73b0\u4e00\u4e2a\u670d\u52a1\u5668\u9650\u6d41\u673a\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-19T00:42:11+00:00","dateModified":"2025-04-19T00:42:11+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/23847.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/23847.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/23847.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u57fa\u4e8eRedis+AOP+Lua\u811a\u672c\u5b9e\u73b0\u4e00\u4e2a\u670d\u52a1\u5668\u9650\u6d41\u673a\u5236"}]},{"@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\/23847","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=23847"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/23847\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=23847"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=23847"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=23847"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=23847"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}