{"id":10006715,"date":"2022-10-21T19:01:42","date_gmt":"2022-10-21T11:01:42","guid":{"rendered":"https:\/\/ityet.com\/?p=10006715"},"modified":"2022-10-21T19:01:42","modified_gmt":"2022-10-21T11:01:42","slug":"%e9%9d%a2%e8%af%95%e5%ae%98%ef%bc%9aredis-%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e6%af%8f%e5%91%a8%e7%83%ad%e8%af%84%e5%8a%9f%e8%83%bd%ef%bc%9f%e8%af%b4%e8%af%b4%e6%80%9d%e8%b7%af%ef%bc%81","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10006715","title":{"rendered":"\u9762\u8bd5\u5b98\uff1aRedis \u5982\u4f55\u5b9e\u73b0\u6bcf\u5468\u70ed\u8bc4\u529f\u80fd\uff1f\u8bf4\u8bf4\u601d\u8def\uff01"},"content":{"rendered":"<h4>\u601d\u8def\u5206\u6790<\/h4>\n<p>\u505a\u6bcf\u5468\u70ed\u8bae\uff0c\u5e94\u8be5\u7528\u7f13\u5b58\u6765\u505a\uff0c\u5982\u679c\u76f4\u63a5\u67e5\u5e93\u7684\u8bdd\uff0c\u4f1a\u5bf9\u6570\u636e\u5e93\u9020\u6210\u538b\u529b\u3002\u7528\u7f13\u5b58\u505a\u7684\u8bdd\uff0c\u7528Redis \u6765\u505a\u7f13\u5b58\u7684\u8bdd\u6bd4\u8f83\u5408\u9002\u4e00\u70b9\u3002<\/p>\n<pre><code># \u5229\u7528Redsi \u6dfb\u52a0 \u6570\u636e\u547d\u4ee4\n# day:1 \u6307\u7684\u662f\u57281\u53f7\u7684\u65f6\u5019 post:1 \u7b2c\u4e00\u7bc7\u6587\u7ae0\u6dfb\u52a0\u4e86 10 \u6761\u8bc4\u8bba\u3002\n#\u540e\u9762 6 post:2 \u6307\u7684\u662f \u57281\u53f7\u7b2c\u4e8c\u7bc7\u6dfb\u52a0\u4e866\u6761\u8bc4\u8bba\nzadd day:1 10 post:1 6 post:2\nzadd day:2 10 post:1 6 post:2\nzadd day:3 10 post:1 6 post:2\n....\nzadd day:8 10 post:1 6 post:2\n#\u8fd9\u6837\u5c31\u5b8c\u6210\u4e867\u5929\u7684\u8bb0\u5f55<\/code><\/pre>\n<p>\u4e0a\u9762\u7684\u547d\u4ee4\u53ef\u4ee5\u5e2e\u6211\u4eec\u8bb0\u5f55\u4e00\u4e0b7\u5929\u7684\u6240\u6709\u7684\u8bc4\u8bba\u6570\u3002\u4f46\u662f\u8fd8\u6ca1\u6709\u5e2e\u6211\u4eec\u8ba1\u7b97\u51fa\u6765\u8c01\u662f\u8bc4\u8bba\u6700\u9ad8\u7684\u3002\u770bRedis \u7684sorted set\u6709\u5e8f\u96c6\u5408\u6709\u4e2a\u547d\u4ee4\u5c31\u53ef\u4ee5\u5e2e\u6211\u4eec\u5b9e\u73b0\u8fd9\u4e2a\u529f\u80fd\u3002<\/p>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5b9e\u73b0\u5e76\u96c6\uff0c\u6211\u4eec\u53ea\u9700\u8981\u628a7\u5929\u7684\u8bc4\u8bba\u7ed9\u505a\u4e2a\u5e76\u96c6\u5c31\u53ef\u4ee5\u6c42\u51fa\u6765\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc29RP\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<pre><code># Redis \u547d\u4ee4\n#\u610f\u601d\u662f\u5e76\u96c6\u628a\u8fd97\u5929\u7684 \u653e\u5230\u4e00\u4e2a\u65b0\u7684\u96c6\u5408\u91cc\u9762 \u65b0\u7684\u96c6\u5408\u662f week:rank \u8fd9\u6837\u8fd9\u4e2a\u65b0\u7684\u96c6\u5408\u91cc\u9762\u5c31\u6709\u4e86\u6211\u4eec\u7684\n#7\u5929\u7684\u8bb0\u5f55\u4e86\nunion week:rank 7 day:1...day:8<\/code><\/pre>\n<h4>Redis \u547d\u4ee4\u5b9e\u8df5\u4e00\u4e0b\u770b\u770b<\/h4>\n<p>\u672c\u5730\u547d\u4ee4\u884c\u6d4b\u8bd5<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc29RQ\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<pre><code>127.0.0.1:6379&gt; ping\nPONG\n127.0.0.1:6379&gt; zadd day:1 10 post:1\n(integer) 1\n127.0.0.1:6379&gt; zadd day:2 10 post:1\n(integer) 1\n127.0.0.1:6379&gt; zadd day:3 10 post:1\n(integer) 1\n127.0.0.1:6379&gt; zadd day:1 5 post:2\n(integer) 1\n127.0.0.1:6379&gt; zadd day:2 5 post:2\n(integer) 1\n127.0.0.1:6379&gt; zadd day:3 5 post:2\n(integer) 1\n127.0.0.1:6379&gt; keys *\n1) &quot;day:1&quot;\n2) &quot;day:2&quot;\n3) &quot;day:3&quot;<\/code><\/pre>\n<p>\u67e5\u770b\u5f53\u5929\u7684\u6392\u884c\u699c\u547d\u4ee4 <code>ZRevrange<\/code><\/p>\n<pre><code>127.0.0.1:6379&gt; zrevrange day:1 0 -1 withscores\n1) &quot;post:1&quot;\n2) &quot;10&quot;\n3) &quot;post:2&quot;\n4) &quot;5&quot;\n127.0.0.1:6379&gt;<\/code><\/pre>\n<p>\u6bcf\u5468\u7684\u8bc4\u8bba\u6392\u884c\u699c\u8bb0\u5f55\u3002\u56e0\u4e3a\u6211\u53ea\u6709\u4e09\u5929\u7684\uff0c\u6240\u4ee5\u53ea\u5199\u4e863\u5929\u7684<\/p>\n<pre><code>127.0.0.1:6379&gt; zrevrange week:rank 0 -1 withscores\n1) &quot;post:1&quot;\n2) &quot;30&quot;\n3) &quot;post:2&quot;\n4) &quot;15&quot;\n127.0.0.1:6379&gt;<\/code><\/pre>\n<p>\u4e0a\u9762\u7684\u8bb0\u5f55\u662f\u6ca1\u6709\u9519\u8bef\u7684\u3002\u4e0a\u8ff0\u7684\u547d\u4ee4\u53ef\u4ee5\u5e2e\u6211\u4eec\u7b80\u5355\u7684\u5b9e\u73b0\u4e86\u6211\u4eec\u7684\u60f3\u6cd5\uff0c\u4e0b\u9762\u7528\u4ee3\u7801\u6765\u5b9e\u73b0\u3002\u4e0a\u9762\u8fd8\u6709\u4e00\u4e2a\u5c0f\u7684 bug \u5c31\u662f\u5f53<code>day:1<\/code>\u8fd9\u4e00\u5929\u53ef\u80fd\u4f1a\u51fa\u73b0\u5c31\u662f\u4e0d\u53ef\u80fd\u76f4\u63a5\u5c31\u8fc7\u5b8c\u4e86\u3002\u53ef\u80fd\u4f1a\u4e00\u6761\u4e00\u6761\u7684\u589e\u52a0\uff0c\u8fd9\u4e2a\u65f6\u5019\u5e94\u8be5\u4f7f\u7528\u7684\u662f\u81ea\u589e\u8fd9\u4e2a\u547d\u4ee4\u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n<pre><code>#\u4ec0\u4e48\u65f6\u5019+1 \u4ec0\u4e48\u65f6\u5019-1 \u5c31\u662f\u5f53\u4f60 \u6dfb\u52a0\u4e00\u6761\u8bc4\u8bba\u7684\u65f6\u5019\u5c31\u6dfb\u52a01 \u5220\u9664\u7684\u7684\u65f6\u5019\u5c31\u51cf1\nZINCRBY day:1 10 post:1<\/code><\/pre>\n<h4>\u4ee3\u7801\u6765\u8fdb\u884c\u5b9e\u73b0<\/h4>\n<p>\u76ee\u524d\u524d\u7aef\u7684\u6837\u5f0f\uff0c\u8fd9\u6837\u7684\u8bdd\u6211\u4eec\u5c31\u9700\u8981\u5728\u9879\u76ee\u4e00\u5f00\u59cb\u7684\u65f6\u5019\u5c31\u542f\u52a8\u8fd9\u4e2a\u529f\u80fd<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc29RR\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc29RS\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<pre><code>@Component\n\/\/ \u5b9e\u73b0 \u542f\u52a8\u7c7b \uff0c\u8fd8\u6709 \u4e0a\u4e0b\u6587\u7684servlect\npublic class ContextStartup implements ApplicationRunner, ServletContextAware {\n    \/\/ \u6ce8\u5165 categoryService\n    @Autowired\n    IMCategoryService categoryService;\n    ServletContext servletContext;\n    \/\/ \u6ce8\u5165post \u7684\u670d\u52a1\u7c7b\n    @Autowired\n    IMPostService postService;\n\n    @Override\n    public void run(ApplicationArguments args) throws Exception {\n        \/\/ \u8c03\u7528\u5168\u67e5\u7684\u65b9\u6cd5\n        List&lt;MCategory&gt; list = categoryService.list(new QueryWrapper&lt;MCategory&gt;().eq(&quot;status&quot;, 0));\n        servletContext.setAttribute(&quot;List&quot;, list);\n        \/\/ \u8c03\u7528\u6bcf\u5468\u70ed\u8bc4\u7684\u65b9\u6cd5\n        postService.initweek();\n    }\n\n    @Override\n    public void setServletContext(ServletContext servletContext) {\n        this.servletContext = servletContext;\n    }\n}<\/code><\/pre>\n<h5>\u670d\u52a1\u7c7bserviceimpl\u7c7b<\/h5>\n<p>\u5927\u6982\u7684\u601d\u8def<\/p>\n<ul>\n<li>\u83b7\u53d67\u5929\u5185\u53d1\u8868\u7684\u6587\u7ae0<\/li>\n<li>\u521d\u59cb\u5316\u6587\u7ae0\u7684\u603b\u9605\u8bfb\u91cf<\/li>\n<li>\n<ul>\n<li>\u7f13\u5b58\u6587\u7ae0\u7684\u57fa\u672c\u4fe1\u606f\uff08id,\u6807\u9898\uff0c\u8bc4\u8bba\u6570\uff0c\u4f5c\u8005 ID \uff09<\/li>\n<li>\u8fd9\u6837\u5c31\u53ef\u4ee5\u907f\u514d\u7684\u67e5\u5e93\u3002\u53ef\u4ee5\u76f4\u63a5\u7528\u6211\u4eec\u7684\u7f13\u5b58\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u505a\u5e76\u96c6<\/li>\n<\/ul>\n<p>\u8fd9\u91cc\u9700\u8981\u4e00\u4e2aRedis \u7684\u5de5\u5177\u7c7b\uff0c\u6211\u5728\u7f51\u4e0a\u627e\u5230\u7684\uff0c\u4e0d\u662f\u6211\u5199\u7684\u3002\u7f51\u4e0a\u4e00\u5927\u5806\u3002\u76f4\u63a5\u62ff\u6765\u7528\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>\u63a8\u8350\u4e00\u4e2a\u5f00\u6e90\u514d\u8d39\u7684 Spring Boot \u6700\u5168\u6559\u7a0b\uff1a<\/p>\n<blockquote><p><a href=\"https:\/\/link.segmentfault.com\/?enc=HKBB71aI%2FGAd5MI1wuykEA%3D%3D.bKmTa4ZdaraddQLro1sqLHCFYMpFRFXJHhRL4Wpi6u0BtfjWDw0foHdIMSSYoJ1fhtFeKflAeiy589jGawX10A%3D%3D\" rel=\"nofollow\">https:\/\/github.com\/javastacks\/spring-boot-best-practice<\/a><\/p><\/blockquote>\n<pre><code>package com.example.springbootblog.util;\n\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.data.redis.core.RedisTemplate;\nimport org.springframework.data.redis.core.ZSetOperations;\nimport org.springframework.stereotype.Component;\nimport org.springframework.util.CollectionUtils;\n\nimport java.util.Collection;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Set;\nimport java.util.concurrent.TimeUnit;\n\n@Component\npublic class RedisUtil {\n\n    @Autowired\n    private RedisTemplate redisTemplate;\n\n    \/**\n     * \u6307\u5b9a\u7f13\u5b58\u5931\u6548\u65f6\u95f4\n     *\n     * @param key  \u952e\n     * @param time \u65f6\u95f4(\u79d2)\n     * @return\n     *\/\n    public boolean expire(String key, long time) {\n        try {\n            if (time &gt; 0) {\n                redisTemplate.expire(key, time, TimeUnit.SECONDS);\n            }\n            return true;\n        } catch (Exception e) {\n            e.printStackTrace();\n            return false;\n        }\n    }\n\n    \/**\n     * \u6839\u636ekey \u83b7\u53d6\u8fc7\u671f\u65f6\u95f4\n     *\n     * @param key \u952e \u4e0d\u80fd\u4e3anull\n     * @return \u65f6\u95f4(\u79d2) \u8fd4\u56de0\u4ee3\u8868\u4e3a\u6c38\u4e45\u6709\u6548\n     *\/\n    public long getExpire(String key) {\n        return redisTemplate.getExpire(key, TimeUnit.SECONDS);\n    }\n\n    \/**\n     * \u5224\u65adkey\u662f\u5426\u5b58\u5728\n     *\n     * @param key \u952e\n     * @return true \u5b58\u5728 false\u4e0d\u5b58\u5728\n     *\/\n    public boolean hasKey(String key) {\n        try {\n            return redisTemplate.hasKey(key);\n        } catch (Exception e) {\n            e.printStackTrace();\n            return false;\n        }\n    }\n\n    \/**\n     * \u5220\u9664\u7f13\u5b58\n     *\n     * @param key \u53ef\u4ee5\u4f20\u4e00\u4e2a\u503c \u6216\u591a\u4e2a\n     *\/\n    @SuppressWarnings(&quot;unchecked&quot;)\n    public void del(String... key) {\n        if (key != null &amp;&amp; key.length &gt; 0) {\n            if (key.length == 1) {\n                redisTemplate.delete(key[0]);\n            } else {\n                redisTemplate.delete(CollectionUtils.arrayToList(key));\n            }\n        }\n    }\n\n    \/\/============================String=============================\n\n    \/**\n     * \u666e\u901a\u7f13\u5b58\u83b7\u53d6\n     *\n     * @param key \u952e\n     * @return \u503c\n     *\/\n    public Object get(String key) {\n        return key == null ? null : redisTemplate.opsForValue().get(key);\n    }\n\n    \/**\n     * \u666e\u901a\u7f13\u5b58\u653e\u5165\n     *\n     * @param key   \u952e\n     * @param value \u503c\n     * @return true\u6210\u529f false\u5931\u8d25\n     *\/\n    public boolean set(String key, Object value) {\n        try {\n            redisTemplate.opsForValue().set(key, value);\n            return true;\n        } catch (Exception e) {\n            e.printStackTrace();\n            return false;\n        }\n\n    }\n\n    \/**\n     * \u666e\u901a\u7f13\u5b58\u653e\u5165\u5e76\u8bbe\u7f6e\u65f6\u95f4\n     *\n     * @param key   \u952e\n     * @param value \u503c\n     * @param time  \u65f6\u95f4(\u79d2) time\u8981\u5927\u4e8e0 \u5982\u679ctime\u5c0f\u4e8e\u7b49\u4e8e0 \u5c06\u8bbe\u7f6e\u65e0\u9650\u671f\n     * @return true\u6210\u529f false \u5931\u8d25\n     *\/\n    public boolean set(String key, Object value, long time) {\n        try {\n            if (time &gt; 0) {\n                redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);\n            } else {\n                set(key, value);\n            }\n            return true;\n        } catch (Exception e) {\n            e.printStackTrace();\n            return false;\n        }\n    }\n\n    \/**\n     * \u9012\u589e\n     *\n     * @param key \u952e\n     * @param delta  \u8981\u589e\u52a0\u51e0(\u5927\u4e8e0)\n     * @return\n     *\/\n    public long incr(String key, long delta) {\n        if (delta &lt; 0) {\n            throw new RuntimeException(&quot;\u9012\u589e\u56e0\u5b50\u5fc5\u987b\u5927\u4e8e0&quot;);\n        }\n        return redisTemplate.opsForValue().increment(key, delta);\n    }\n\n    \/**\n     * \u9012\u51cf\n     *\n     * @param key \u952e\n     * @param delta  \u8981\u51cf\u5c11\u51e0(\u5c0f\u4e8e0)\n     * @return\n     *\/\n    public long decr(String key, long delta) {\n        if (delta &lt; 0) {\n            throw new RuntimeException(&quot;\u9012\u51cf\u56e0\u5b50\u5fc5\u987b\u5927\u4e8e0&quot;);\n        }\n        return redisTemplate.opsForValue().increment(key, -delta);\n    }\n\n    \/\/================================Map=================================\n\n    \/**\n     * HashGet\n     *\n     * @param key  \u952e \u4e0d\u80fd\u4e3anull\n     * @param item \u9879 \u4e0d\u80fd\u4e3anull\n     * @return \u503c\n     *\/\n    public Object hget(String key, String item) {\n        return redisTemplate.opsForHash().get(key, item);\n    }\n\n    \/**\n     * \u83b7\u53d6hashKey\u5bf9\u5e94\u7684\u6240\u6709\u952e\u503c\n     *\n     * @param key \u952e\n     * @return \u5bf9\u5e94\u7684\u591a\u4e2a\u952e\u503c\n     *\/\n    public Map&lt;Object, Object&gt; hmget(String key) {\n        return redisTemplate.opsForHash().entries(key);\n    }\n\n    \/**\n     * HashSet\n     *\n     * @param key \u952e\n     * @param map \u5bf9\u5e94\u591a\u4e2a\u952e\u503c\n     * @return true \u6210\u529f false \u5931\u8d25\n     *\/\n    public boolean hmset(String key, Map&lt;String, Object&gt; map) {\n        try {\n            redisTemplate.opsForHash().putAll(key, map);\n            return true;\n        } catch (Exception e) {\n            e.printStackTrace();\n            return false;\n        }\n    }\n\n    \/**\n     * HashSet \u5e76\u8bbe\u7f6e\u65f6\u95f4\n     *\n     * @param key  \u952e\n     * @param map  \u5bf9\u5e94\u591a\u4e2a\u952e\u503c\n     * @param time \u65f6\u95f4(\u79d2)\n     * @return true\u6210\u529f false\u5931\u8d25\n     *\/\n    public boolean hmset(String key, Map&lt;String, Object&gt; map, long time) {\n        try {\n            redisTemplate.opsForHash().putAll(key, map);\n            if (time &gt; 0) {\n                expire(key, time);\n            }\n            return true;\n        } catch (Exception e) {\n            e.printStackTrace();\n            return false;\n        }\n    }\n\n    \/**\n     * \u5411\u4e00\u5f20hash\u8868\u4e2d\u653e\u5165\u6570\u636e,\u5982\u679c\u4e0d\u5b58\u5728\u5c06\u521b\u5efa\n     *\n     * @param key   \u952e\n     * @param item  \u9879\n     * @param value \u503c\n     * @return true \u6210\u529f false\u5931\u8d25\n     *\/\n    public boolean hset(String key, String item, Object value) {\n        try {\n            redisTemplate.opsForHash().put(key, item, value);\n            return true;\n        } catch (Exception e) {\n            e.printStackTrace();\n            return false;\n        }\n    }\n\n    \/**\n     * \u5411\u4e00\u5f20hash\u8868\u4e2d\u653e\u5165\u6570\u636e,\u5982\u679c\u4e0d\u5b58\u5728\u5c06\u521b\u5efa\n     *\n     * @param key   \u952e\n     * @param item  \u9879\n     * @param value \u503c\n     * @param time  \u65f6\u95f4(\u79d2)  \u6ce8\u610f:\u5982\u679c\u5df2\u5b58\u5728\u7684hash\u8868\u6709\u65f6\u95f4,\u8fd9\u91cc\u5c06\u4f1a\u66ff\u6362\u539f\u6709\u7684\u65f6\u95f4\n     * @return true \u6210\u529f false\u5931\u8d25\n     *\/\n    public boolean hset(String key, String item, Object value, long time) {\n        try {\n            redisTemplate.opsForHash().put(key, item, value);\n            if (time &gt; 0) {\n                expire(key, time);\n            }\n            return true;\n        } catch (Exception e) {\n            e.printStackTrace();\n            return false;\n        }\n    }\n\n    \/**\n     * \u5220\u9664hash\u8868\u4e2d\u7684\u503c\n     *\n     * @param key  \u952e \u4e0d\u80fd\u4e3anull\n     * @param item \u9879 \u53ef\u4ee5\u4f7f\u591a\u4e2a \u4e0d\u80fd\u4e3anull\n     *\/\n    public void hdel(String key, Object... item) {\n        redisTemplate.opsForHash().delete(key, item);\n    }\n\n    \/**\n     * \u5224\u65adhash\u8868\u4e2d\u662f\u5426\u6709\u8be5\u9879\u7684\u503c\n     *\n     * @param key  \u952e \u4e0d\u80fd\u4e3anull\n     * @param item \u9879 \u4e0d\u80fd\u4e3anull\n     * @return true \u5b58\u5728 false\u4e0d\u5b58\u5728\n     *\/\n    public boolean hHasKey(String key, String item) {\n        return redisTemplate.opsForHash().hasKey(key, item);\n    }\n\n    \/**\n     * hash\u9012\u589e \u5982\u679c\u4e0d\u5b58\u5728,\u5c31\u4f1a\u521b\u5efa\u4e00\u4e2a \u5e76\u628a\u65b0\u589e\u540e\u7684\u503c\u8fd4\u56de\n     *\n     * @param key  \u952e\n     * @param item \u9879\n     * @param by   \u8981\u589e\u52a0\u51e0(\u5927\u4e8e0)\n     * @return\n     *\/\n    public double hincr(String key, String item, double by) {\n        return redisTemplate.opsForHash().increment(key, item, by);\n    }\n\n    \/**\n     * hash\u9012\u51cf\n     *\n     * @param key  \u952e\n     * @param item \u9879\n     * @param by   \u8981\u51cf\u5c11\u8bb0(\u5c0f\u4e8e0)\n     * @return\n     *\/\n    public double hdecr(String key, String item, double by) {\n        return redisTemplate.opsForHash().increment(key, item, -by);\n    }\n\n    \/\/============================set=============================\n\n    \/**\n     * \u6839\u636ekey\u83b7\u53d6Set\u4e2d\u7684\u6240\u6709\u503c\n     *\n     * @param key \u952e\n     * @return\n     *\/\n    public Set&lt;Object&gt; sGet(String key) {\n        try {\n            return redisTemplate.opsForSet().members(key);\n        } catch (Exception e) {\n            e.printStackTrace();\n            return null;\n        }\n    }\n\n    \/**\n     * \u6839\u636evalue\u4ece\u4e00\u4e2aset\u4e2d\u67e5\u8be2,\u662f\u5426\u5b58\u5728\n     *\n     * @param key   \u952e\n     * @param value \u503c\n     * @return true \u5b58\u5728 false\u4e0d\u5b58\u5728\n     *\/\n    public boolean sHasKey(String key, Object value) {\n        try {\n            return redisTemplate.opsForSet().isMember(key, value);\n        } catch (Exception e) {\n            e.printStackTrace();\n            return false;\n        }\n    }\n\n    \/**\n     * \u5c06\u6570\u636e\u653e\u5165set\u7f13\u5b58\n     *\n     * @param key    \u952e\n     * @param values \u503c \u53ef\u4ee5\u662f\u591a\u4e2a\n     * @return \u6210\u529f\u4e2a\u6570\n     *\/\n    public long sSet(String key, Object... values) {\n        try {\n            return redisTemplate.opsForSet().add(key, values);\n        } catch (Exception e) {\n            e.printStackTrace();\n            return 0;\n        }\n    }\n\n    \/**\n     * \u5c06set\u6570\u636e\u653e\u5165\u7f13\u5b58\n     *\n     * @param key    \u952e\n     * @param time   \u65f6\u95f4(\u79d2)\n     * @param values \u503c \u53ef\u4ee5\u662f\u591a\u4e2a\n     * @return \u6210\u529f\u4e2a\u6570\n     *\/\n    public long sSetAndTime(String key, long time, Object... values) {\n        try {\n            Long count = redisTemplate.opsForSet().add(key, values);\n            if (time &gt; 0) expire(key, time);\n            return count;\n        } catch (Exception e) {\n            e.printStackTrace();\n            return 0;\n        }\n    }\n\n    \/**\n     * \u83b7\u53d6set\u7f13\u5b58\u7684\u957f\u5ea6\n     *\n     * @param key \u952e\n     * @return\n     *\/\n    public long sGetSetSize(String key) {\n        try {\n            return redisTemplate.opsForSet().size(key);\n        } catch (Exception e) {\n            e.printStackTrace();\n            return 0;\n        }\n    }\n\n    \/**\n     * \u79fb\u9664\u503c\u4e3avalue\u7684\n     *\n     * @param key    \u952e\n     * @param values \u503c \u53ef\u4ee5\u662f\u591a\u4e2a\n     * @return \u79fb\u9664\u7684\u4e2a\u6570\n     *\/\n    public long setRemove(String key, Object... values) {\n        try {\n            Long count = redisTemplate.opsForSet().remove(key, values);\n            return count;\n        } catch (Exception e) {\n            e.printStackTrace();\n            return 0;\n        }\n    }\n    \/\/===============================list=================================\n\n    \/**\n     * \u83b7\u53d6list\u7f13\u5b58\u7684\u5185\u5bb9\n     *\n     * @param key   \u952e\n     * @param start \u5f00\u59cb\n     * @param end   \u7ed3\u675f  0 \u5230 -1\u4ee3\u8868\u6240\u6709\u503c\n     * @return\n     *\/\n    public List&lt;Object&gt; lGet(String key, long start, long end) {\n        try {\n            return redisTemplate.opsForList().range(key, start, end);\n        } catch (Exception e) {\n            e.printStackTrace();\n            return null;\n        }\n    }\n\n    \/**\n     * \u83b7\u53d6list\u7f13\u5b58\u7684\u957f\u5ea6\n     *\n     * @param key \u952e\n     * @return\n     *\/\n    public long lGetListSize(String key) {\n        try {\n            return redisTemplate.opsForList().size(key);\n        } catch (Exception e) {\n            e.printStackTrace();\n            return 0;\n        }\n    }\n\n    \/**\n     * \u901a\u8fc7\u7d22\u5f15 \u83b7\u53d6list\u4e2d\u7684\u503c\n     *\n     * @param key   \u952e\n     * @param index \u7d22\u5f15  index&gt;=0\u65f6\uff0c 0 \u8868\u5934\uff0c1 \u7b2c\u4e8c\u4e2a\u5143\u7d20\uff0c\u4f9d\u6b21\u7c7b\u63a8\uff1bindex&lt;0\u65f6\uff0c-1\uff0c\u8868\u5c3e\uff0c-2\u5012\u6570\u7b2c\u4e8c\u4e2a\u5143\u7d20\uff0c\u4f9d\u6b21\u7c7b\u63a8\n     * @return\n     *\/\n    public Object lGetIndex(String key, long index) {\n        try {\n            return redisTemplate.opsForList().index(key, index);\n        } catch (Exception e) {\n            e.printStackTrace();\n            return null;\n        }\n    }\n\n    \/**\n     * \u5c06list\u653e\u5165\u7f13\u5b58\n     *\n     * @param key   \u952e\n     * @param value \u503c\n     * @return\n     *\/\n    public boolean lSet(String key, Object value) {\n        try {\n            redisTemplate.opsForList().rightPush(key, value);\n            return true;\n        } catch (Exception e) {\n            e.printStackTrace();\n            return false;\n        }\n    }\n\n    \/**\n     * \u5c06list\u653e\u5165\u7f13\u5b58\n     *\n     * @param key   \u952e\n     * @param value \u503c\n     * @param time  \u65f6\u95f4(\u79d2)\n     * @return\n     *\/\n    public boolean lSet(String key, Object value, long time) {\n        try {\n            redisTemplate.opsForList().rightPush(key, value);\n            if (time &gt; 0) expire(key, time);\n            return true;\n        } catch (Exception e) {\n            e.printStackTrace();\n            return false;\n        }\n    }\n\n    \/**\n     * \u5c06list\u653e\u5165\u7f13\u5b58\n     *\n     * @param key   \u952e\n     * @param value \u503c\n     * @return\n     *\/\n    public boolean lSet(String key, List&lt;Object&gt; value) {\n        try {\n            redisTemplate.opsForList().rightPushAll(key, value);\n            return true;\n        } catch (Exception e) {\n            e.printStackTrace();\n            return false;\n        }\n    }\n\n    \/**\n     * \u5c06list\u653e\u5165\u7f13\u5b58\n     *\n     * @param key   \u952e\n     * @param value \u503c\n     * @param time  \u65f6\u95f4(\u79d2)\n     * @return\n     *\/\n    public boolean lSet(String key, List&lt;Object&gt; value, long time) {\n        try {\n            redisTemplate.opsForList().rightPushAll(key, value);\n            if (time &gt; 0) expire(key, time);\n            return true;\n        } catch (Exception e) {\n            e.printStackTrace();\n            return false;\n        }\n    }\n\n    \/**\n     * \u6839\u636e\u7d22\u5f15\u4fee\u6539list\u4e2d\u7684\u67d0\u6761\u6570\u636e\n     *\n     * @param key   \u952e\n     * @param index \u7d22\u5f15\n     * @param value \u503c\n     * @return\n     *\/\n    public boolean lUpdateIndex(String key, long index, Object value) {\n        try {\n            redisTemplate.opsForList().set(key, index, value);\n            return true;\n        } catch (Exception e) {\n            e.printStackTrace();\n            return false;\n        }\n    }\n\n    \/**\n     * \u79fb\u9664N\u4e2a\u503c\u4e3avalue\n     *\n     * @param key   \u952e\n     * @param count \u79fb\u9664\u591a\u5c11\u4e2a\n     * @param value \u503c\n     * @return \u79fb\u9664\u7684\u4e2a\u6570\n     *\/\n    public long lRemove(String key, long count, Object value) {\n        try {\n            Long remove = redisTemplate.opsForList().remove(key, count, value);\n            return remove;\n        } catch (Exception e) {\n            e.printStackTrace();\n            return 0;\n        }\n    }\n\n    \/\/================\u6709\u5e8f\u96c6\u5408 sort set===================\n    \/**\n     * \u6709\u5e8fset\u6dfb\u52a0\u5143\u7d20\n     *\n     * @param key\n     * @param value\n     * @param score\n     * @return\n     *\/\n    public boolean zSet(String key, Object value, double score) {\n        return redisTemplate.opsForZSet().add(key, value, score);\n    }\n\n    public long batchZSet(String key, Set&lt;ZSetOperations.TypedTuple&gt; typles) {\n        return redisTemplate.opsForZSet().add(key, typles);\n    }\n\n    public void zIncrementScore(String key, Object value, long delta) {\n        redisTemplate.opsForZSet().incrementScore(key, value, delta);\n    }\n\n    public void zUnionAndStore(String key, Collection otherKeys, String destKey) {\n        redisTemplate.opsForZSet().unionAndStore(key, otherKeys, destKey);\n    }\n\n    \/**\n     * \u83b7\u53d6zset\u6570\u91cf\n     * @param key\n     * @param value\n     * @return\n     *\/\n    public long getZsetScore(String key, Object value) {\n        Double score = redisTemplate.opsForZSet().score(key, value);\n        if(score==null){\n            return 0;\n        }else{\n            return score.longValue();\n        }\n    }\n\n    \/**\n     * \u83b7\u53d6\u6709\u5e8f\u96c6 key \u4e2d\u6210\u5458 member \u7684\u6392\u540d \u3002\n     * \u5176\u4e2d\u6709\u5e8f\u96c6\u6210\u5458\u6309 score \u503c\u9012\u51cf (\u4ece\u5927\u5230\u5c0f) \u6392\u5e8f\u3002\n     * @param key\n     * @param start\n     * @param end\n     * @return\n     *\/\n    public Set&lt;ZSetOperations.TypedTuple&gt; getZSetRank(String key, long start, long end) {\n        return redisTemplate.opsForZSet().reverseRangeWithScores(key, start, end);\n    }\n\n}<\/code><\/pre>\n<p>\u5b9e\u73b0\u7c7b\u7684\u4ee3\u7801<\/p>\n<pre><code>\/\/ \u6bcf\u5468\u70ed\u8bc4\u7684\u65b9\u6cd5\n@Override\npublic void initweek() {\n    \/\/\u83b7\u53d6 7\u5929\u7684\u6587\u7ae0\n    List&lt;MPost&gt; posts = this.list(new QueryWrapper&lt;MPost&gt;().ge(&quot;created&quot;, DateUtil.lastWeek())\n              .select(&quot;id&quot;, &quot;title&quot;, &quot;user_id&quot;, &quot;comment_count&quot;, &quot;view_count&quot;, &quot;created&quot;)\n      );\/\/ \u83b7\u53d6\u52307\u5929\u524d\u7684\u4ee5\u53ca\u6309\u7167\u8fd9\u51e0\u4e2a\u67e5\u8be2\uff0c\u4e0d\u9700\u8981\u5168\u90e8\u67e5\u8be2\n      \/\/ \u521d\u59cb\u5316\u6587\u7ae0\u7684\u603b\u8bc4\u8bba\n      for (MPost post : posts) {\n          \/\/ \u8bbe\u7f6e key\n          String key = &quot;day:rank:&quot; + DateUtil.format(post.getCreated(), DatePattern.PURE_DATE_FORMAT);\n          \/\/ \u7f13\u5b58\u8fdb\u53bb\u7684\u8bc4\u8bba\u6570\u91cf\n          redisUtil.zSet(key, post.getId(), post.getCommentCount());\n          \/\/\u8bbe\u7f6e\u81ea\u52a8\u8fc7\u671f 7\u5929\u8fc7\u671f\n          long between = DateUtil.between(new Date(), post.getCreated(), DateUnit.DAY);\n          long expireTime = (7 - between) * 24 * 60 * 60; \/\/ \u6709\u6548 \u65f6\u95f4\n\n          redisUtil.expire(key, expireTime);\n          \/\/ \u7f13\u5b58\u6587\u7ae0\u7684\u4e00\u4e9b\u57fa\u672c\u4fe1\u606f\n          this.hashCachePost(post, expireTime);\n      }\n      \/\/ \u505a\u5e76\u96c6\n      this.zunionAndStore();\n}\n\n \/**\n  * \u6587\u7ae0\u6bcf\u5468\u8bc4\u8bba\u6570\u91cf\u5e76\u96c6\u64cd\u4f5c\n  **\/\n private void zunionAndStore() {\n     String destkey = &quot;day:rank:&quot; + DateUtil.format(new Date(), DatePattern.PURE_DATE_FORMAT);\n     \/\/ \u8bbe\u7f6e\u5e76\u96c6\u540e\u7684\u65b0\u7684 key\n     String newkey = &quot;week:rank&quot;;\n     ArrayList&lt;String&gt; otherKeys = new ArrayList&lt;&gt;();\n     \/\/ \u8ba1\u7b977\u5929\u7684\n     for (int i = -6; i &lt; 0; i++) {\n         String temp = &quot;day:rank:&quot; + DateUtil.format(DateUtil.offsetDay(new Date(), i), DatePattern.PURE_DATE_FORMAT);\n         otherKeys.add(temp);\n     }\n     redisUtil.zUnionAndStore(destkey, otherKeys, newkey);\n }\n\n \/**\n  * \u6587\u7ae0\u4f5c\u8005\u7f13\u5b58\n  **\/\n private void hashCachePost(MPost post, long expireTime) {\n     \/\/ \u8bbe\u7f6e key\n     String key = &quot;rank:post:&quot; + post.getId();\n     \/\/ \u5224\u65ad\u5b58\u5728\u4e0d\u5b58\u5728\n     boolean hasKey = redisUtil.hasKey(key);\n     if (!hasKey) {\n         \/\/ \u5c31\u5b58\u5230\u7f13\u5b58\u91cc\u9762\n         redisUtil.hset(key, &quot;post:id&quot;, post.getId(), expireTime);\n         redisUtil.hset(key, &quot;post:title&quot;, post.getTitle(), expireTime);\n         redisUtil.hset(key, &quot;post:commentCount&quot;, post.getCommentCount(), expireTime);\n\n     }\n }\n}<\/code><\/pre>\n<p>\u8fd9\u6837\u5c31\u53ef\u4ee5\u628a\u6211\u4eec\u7684\u547d\u4ee4\u884c\u8f6c\u6362\u6210\u4ee3\u7801\u7684\u5f62\u5f0f\u3002\u5c31\u53ef\u4ee5\u628a\u6211\u4eec\u7684\u6570\u636e\u5e93\u7684\u6570\u636e\u5148\u5b58\u5230\u7f13\u5b58\u4e2d\u53bb\u4e86\u3002<\/p>\n<p>\u6548\u679c<\/p>\n<pre><code>127.0.0.1:6379&gt; keys *\n1) &quot;rank:post:4&quot;\n2) &quot;week:rank&quot;\n3) &quot;day:rank:20210724&quot;\n4) &quot;rank:post:3&quot;\n5) &quot;rank:post:2&quot;\n6) &quot;day:rank:20210726&quot;\n#\u67e5\u770b\u6211\u4eec\u5e76\u96c6\u5b8c\u540e\u7684\u6570\u636e id \u4e3a 3 \u7684\u6709 1\u6761\u8bc4\u8bba\u3002\n127.0.0.1:6379&gt; zrevrange week:rank 0 -1 withscores\n1) &quot;3&quot;\n2) &quot;1&quot;\n3) &quot;2&quot;\n4) &quot;1&quot;\n5) &quot;4&quot;\n6) &quot;0&quot;\n127.0.0.1:6379&gt;<\/code><\/pre>\n<p>\u6570\u636e\u5e93\u4e2did \u4e3a 3 \u7684\u6709 1\u6761\u8bc4\u8bba<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc29RT\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc29RT\" alt=\"\u3001\" title=\"\u3001\" loading=\"lazy\"><\/p>\n<p>\u786e\u5b9e\u53ea\u6709\u4e00\u6761\u8bc4\u8bba\u7684<\/p>\n<h4>\u524d\u7aef\u5c55\u793a\u51fa\u6765<\/h4>\n<p>\u8fd9\u91cc\u7684\u601d\u8def\u5c31\u6bd4\u8f83\u7b80\u5355\u4e86\uff0c\u628a\u6211\u4eec\u7684\u6570\u636e\u4ece\u7f13\u5b58\u4e2d\u53d6\u51fa\u6765\u5c31\u53ef\u4ee5\u3002\u7528\u7684freemarker\u53ef\u4ee5\u81ea\u5b9a\u4e49\u6807\u7b7e\u3002\u6211\u81ea\u5b9a\u4e49\u4e86\u6807\u7b7e\u3002<\/p>\n<p>Hosttemplate<\/p>\n<pre><code>\/**\n * \u672c\u5468\u70ed\u8bae\n *\/\n@Component\npublic class HotsTemplate extends TemplateDirective {\n\n    @Autowired\n    RedisUtil redisUtil;\n\n    @Override\n    public String getName() {\n        return &quot;hots&quot;;\n    }\n\n    @Override\n    public void execute(DirectiveHandler handler) throws Exception {\n\/\/ \u8bbe\u7f6e key\n        String key =&quot;week:rank&quot;;\n        Set&lt;ZSetOperations.TypedTuple&gt; zSetRank = redisUtil.getZSetRank(key, 0, 6);\n        ArrayList&lt;Map&gt; maps = new ArrayList&lt;&gt;();\n\n        \/\/ \u4fbf\u5229\n        for (ZSetOperations.TypedTuple typedTuple : zSetRank) {\n            \/\/ \u521b\u5efa Map\n            HashMap&lt;String, Object&gt; map = new HashMap&lt;&gt;();\n            Object post_id = typedTuple.getValue();\n            String PostHashKey = &quot;rank:post:&quot; +post_id;\n            map.put(&quot;id&quot;,post_id);\n            map.put(&quot;title&quot;,redisUtil.hget(PostHashKey,&quot;post:title&quot;));\n            map.put(&quot;commentCount&quot;,typedTuple.getScore());\n            maps.add(map);\n        }\n        handler.put(RESULTS,maps).render();\n    }\n}<\/code><\/pre>\n<p>\u5728<code>FreemarkerConfig<\/code>\u628a\u6211\u4eec\u5199\u7684\u4fbf\u7b7e\u6ce8\u5165\u5c31\u53ef\u4ee5\u4f7f\u7528\u6211\u4eec\u81ea\u5b9a\u4e49\u7684\u6807\u7b7e\u4e86<\/p>\n<pre><code>@Configuration\npublic class FreemarkerConfig {\n\n    @Autowired\n    private freemarker.template.Configuration configuration;\n    @Autowired\n    PostsTemplate postsTemplate;\n    @Autowired\n    HotsTemplate hotsTemplate;\n    @PostConstruct\n    public void setUp() {\n        configuration.setSharedVariable(&quot;timeAgo&quot;, new TimeAgoMethod());\n        configuration.setSharedVariable(&quot;posts&quot;, postsTemplate);\n        configuration.setSharedVariable(&quot;hosts&quot;, hotsTemplate);\n    }\n\n\n}<\/code><\/pre>\n<p>\u524d\u7aef\u7684\u9875\u9762\u83b7\u53d6<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc29RU\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6548\u679c<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc29RV\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h3>\u603b\u7ed3<\/h3>\n<p>\u5728\u505a\u8fd9\u4e2a\u529f\u80fd\u7684\u65f6\u5019\u3002\u4e0d\u591f\u5168\u9762\u3002\u867d\u7136\u5199\u5b8c\u4e86\uff0c\u4f46\u662f\u5e94\u8be5\u662f\u83b7\u53d67\u5929\u5185\u7684\u8bc4\u8bba\u3002\u6211\u83b7\u53d6\u4e867\u5929\u7684\u6587\u7ae0\u3002\u867d\u7136\u662f\u4e2a bug \u4f46\u662f\u6211\u4e0d\u60f3\u4fee\u590d\u3002\u5c31\u8fd9\u6837\u5427\u3002\u73b0\u5728\u80fd\u7528\u5c31\u884c\u3002\u9053\u7406\u662f\u4e00\u6837\u7684\u3002\u5230\u65f6\u5019\u6709\u65f6\u95f4\u51fa\u95ee\u9898\u4e86\u5728\u6539\u5427\u3002\u7d2f\u4e86\uff0c\u65e0\u60c5\u7684\u4ee3\u7801\u673a\u5668\u8bb0\u5f55\u4ee3\u7801\u751f\u6d3b\u4e2d\u3002\u3002\u3002\u3002\u3002<\/p>\n<p>\u6765\u6e90\uff1ablog.csdn.net\/m0_46937429\/article\/details\/119172118<\/p>\n<p><strong>\u8fd1\u671f\u70ed\u6587\u63a8\u8350\uff1a<\/strong><\/p>\n<p>1.<a href=\"https:\/\/link.segmentfault.com\/?enc=Bgi8cVjXK4QGJTHn4XeIkQ%3D%3D.FJ%2Fx0Jwar%2FY3838u6FtxpM35ABGPqRYt55eHcWBF8Eg%3D\" rel=\"nofollow\">1,000+ \u9053 Java\u9762\u8bd5\u9898\u53ca\u7b54\u6848\u6574\u7406(2022\u6700\u65b0\u7248)<\/a><\/p>\n<p>2.<a href=\"https:\/\/link.segmentfault.com\/?enc=6BCeG4JirQG%2Bd8kk4jklxg%3D%3D.c631dQnVr3PXo4XaFCEqk5aBwWFFtdmdZ5Wdkq7Xeyak26K09QY0WcNm5OKoRsEw3KSdXO19uFJtkXaGzs7MXg%3D%3D\" rel=\"nofollow\">\u52b2\u7206\uff01Java \u534f\u7a0b\u8981\u6765\u4e86\u3002\u3002\u3002<\/a><\/p>\n<p>3.<a href=\"https:\/\/link.segmentfault.com\/?enc=%2BiDsrZvmyioGPQVXK44Yjg%3D%3D.rNXzseOdO0F6g%2BsdfuvSKrX39Kduecjb8z3g7eDpZhF7ChaAP%2B0I0q8beJt%2F%2Bzc1\" rel=\"nofollow\">Spring Boot 2.x \u6559\u7a0b\uff0c\u592a\u5168\u4e86\uff01<\/a><\/p>\n<p>4.<a href=\"https:\/\/link.segmentfault.com\/?enc=7KHBAaENCqCTcZ7l6HkHpA%3D%3D.MkFTxPID71HW0uXjuXIsTAFIU7eWPbtbr11mmGgGv4hNDlgcNzLn%2FzFLEqzeJi9eEsOSbWpn35a4zd9JciRWDA%3D%3D\" rel=\"nofollow\">\u522b\u518d\u5199\u6ee1\u5c4f\u7684\u7206\u7206\u7206\u70b8\u7c7b\u4e86\uff0c\u8bd5\u8bd5\u88c5\u9970\u5668\u6a21\u5f0f\uff0c\u8fd9\u624d\u662f\u4f18\u96c5\u7684\u65b9\u5f0f\uff01\uff01<\/a><\/p>\n<p>5.<a href=\"https:\/\/link.segmentfault.com\/?enc=2CXGHc0XkwdR87sAa92Aig%3D%3D.ItTAQsnSkk0MKmpiDqeBG4sAPJCCqP6PBm2d66yp51mJJDzEEzElWwavb96%2B5AKCaQ%2BDpvV9xKxptBRkC2JhB9A19%2FWpntMrDCLabXgo4ZM%3D\" rel=\"nofollow\">\u300aJava\u5f00\u53d1\u624b\u518c\uff08\u5d69\u5c71\u7248\uff09\u300b\u6700\u65b0\u53d1\u5e03\uff0c\u901f\u901f\u4e0b\u8f7d\uff01<\/a><\/p>\n<p>\u89c9\u5f97\u4e0d\u9519\uff0c\u522b\u5fd8\u4e86\u968f\u624b\u70b9\u8d5e+\u8f6c\u53d1\u54e6\uff01<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000042659582\">https:\/\/segmentfault.com\/a\/1190000042659582<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u601d\u8def\u5206\u6790 \u505a\u6bcf\u5468\u70ed\u8bae\uff0c\u5e94\u8be5\u7528\u7f13\u5b58\u6765\u505a\uff0c\u5982\u679c\u76f4\u63a5\u67e5\u5e93\u7684\u8bdd\uff0c\u4f1a\u5bf9\u6570\u636e\u5e93\u9020\u6210\u538b\u529b\u3002\u7528\u7f13\u5b58\u505a\u7684\u8bdd\uff0c\u7528Redis \u6765\u505a\u7f13 [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-10006715","post","type-post","status-publish","format-standard","hentry"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006715","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10006715"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006715\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10006715"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10006715"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10006715"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}