{"id":40233,"date":"2023-02-21T23:27:03","date_gmt":"2023-12-06T01:00:43","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8spring-boot%e6%9d%a5%e4%bd%bf%e7%94%a8spring-data-redis%e3%80%82\/"},"modified":"2024-04-29T15:40:50","modified_gmt":"2024-04-29T07:40:50","slug":"%e4%bd%bf%e7%94%a8spring-boot%e6%9d%a5%e4%bd%bf%e7%94%a8spring-data-redis%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8spring-boot%e6%9d%a5%e4%bd%bf%e7%94%a8spring-data-redis%e3%80%82\/","title":{"rendered":"\u4f7f\u7528Spring Boot\u6765\u4f7f\u7528Spring Data Redis"},"content":{"rendered":"<h1>\u9996\u5148\uff0c\u5148\u884c\u52a8<\/h1>\n<h2>\u6dfb\u52a0\u4f9d\u5b58\u5173\u7cfb<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">maven\u306e\u5834\u5408pom\u306bspring-boot-starter\u3068spring-boot-starter-redis\u3092\u8ffd\u52a0\u3059\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">Spring Data \u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306fJedis\u3092\u5229\u7528\u3057\u3066Redis\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3002<\/ul>\n<pre class=\"post-pre\"><code>&lt;parent&gt;\r\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;\r\n    &lt;version&gt;1.3.0.M5&lt;\/version&gt;\r\n&lt;\/parent&gt;\r\n\r\n&lt;dependencies&gt;\r\n    &lt;dependency&gt;\r\n        &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;spring-boot-starter&lt;\/artifactId&gt;\r\n    &lt;\/dependency&gt;\r\n\r\n    &lt;dependency&gt;\r\n        &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;spring-boot-starter-redis&lt;\/artifactId&gt;\r\n    &lt;\/dependency&gt;\r\n&lt;\/dependencies&gt;\r\n<\/code><\/pre>\n<h2>\u8bbe\u5b9a<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u8d77\u52d5\u30af\u30e9\u30b9\u306b@SpringBootApplication\u3092\u3064\u3051\u308b\u3060\u3051\u3067spring-boot-autoconfigure\u304c\u81ea\u52d5\u7684\u306bRedisTemplate\u3092\u5229\u7528\u53ef\u80fd\u306b\u3057\u3066\u304f\u308c\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306flocalhost:6379\u306b\u63a5\u7d9a\u3059\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u8a2d\u5b9a\u3092\u5909\u66f4\u3057\u305f\u3051\u308c\u3070application.yml\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8f09\u3001\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u30d7\u30fc\u30eb\u306e\u8a2d\u5b9a\u306a\u3069\u3082\u8a18\u8f09\u53ef\u80fd\u3002<\/ul>\n<pre class=\"post-pre\"><code>spring:\r\n    data:\r\n        redis:\r\n            host: 192.168.33.11\r\n            port: 6379   \r\n<\/code><\/pre>\n<h2>\u4f7f\u7528\u7684\u65b9\u5f0f<\/h2>\n<p>\u4f7f\u7528RedisTemplate\u64cd\u4f5cRedis\u3002<\/p>\n<pre class=\"post-pre\"><code>@Autowired\r\nRedisTemplate redisTemplate;\r\n\r\npublic void write() {\r\n\r\n    redisTemplate.opsForZSet().add(userId, itemId ,new Date().getTime()))\r\n\r\n}\r\n\r\npublic List&lt;History&gt; read(long begin , long end) {\r\n    return redisTemplate.opsForZSet().reverseRangeWithScores(null, begin , end))\r\n            .stream().map(e -&gt; {\r\n             History history = new History();\r\n             history.setDate( new Date((long)(e.getScore())));\r\n             history.setItemId( result.getValue());\r\n             return history;\r\n    }).collect(Collectors.toList());\r\n}\r\n<\/code><\/pre>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u4e0a\u8a18\u306fSortedSet\u3092\u5229\u7528\u3057\u305f\u30b5\u30f3\u30d7\u30eb\u3067\u3059\u3002SortedSet\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u3053\u3068\u304c\u53ef\u80fd\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>\u5546\u54c1ID\u306e\u91cd\u8907\u3092\u8a31\u53ef\u3057\u306a\u3044\u305f\u3081\u3001\u540c\u3058\u5546\u54c1\u3092\u4f55\u5ea6\u898b\u3089\u308c\u3066\u30821\u4ef6\u3068\u3057\u3066\u6271\u308f\u308c\u308b<br \/>\n2\u65e5\u524d\u306b\u5546\u54c1A\u3092\u898b\u305f-&gt;1\u65e5\u524d\u306b\u5546\u54c1B\u3092\u898b\u305f-&gt;\u4eca\u65e5\u5546\u54c1A\u3092\u307e\u305f\u898b\u305f\u3001\u306e\u5834\u5408\u306b\u5546\u54c1A\u3092\u5546\u54c1B\u3088\u308a\u512a\u5148\u3059\u308b<\/p>\n<h1>\u5c06spring-context\u7684\u7f13\u5b58\u4e0e\u4e4b\u534f\u540c\u5de5\u4f5c<\/h1>\n<p>\u6211\u6253\u7b97\u5c1d\u8bd5\u5c06Redis\u7528\u4f5c\u7f13\u5b58\u3002<\/p>\n<h2>\u8bbe\u5b9a<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">CachingConfigurerSupport\u30af\u30e9\u30b9\u3092\u7d99\u627f\u3057\u3066CacheManager\u306e\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3059\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>@EnableCaching\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u4ed8\u4e0e\u3082\u5fc5\u8981\u3002<\/p>\n<pre class=\"post-pre\"><code>@Configuration\r\n@EnableCaching\r\npublic class RedisConfiguration extends CachingConfigurerSupport {\r\n\r\n    @Bean\r\n    @Autowired\r\n    public CacheManager cacheManager(RedisTemplate&lt;Object,Object&gt; redisTemplate&gt;){\r\n\r\n        RedisCacheManager cacheManager = new RedisCacheManager(redisTemplate)\r\n\r\n        \/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u6709\u52b9\u671f\u9650\u306e\u8a2d\u5b9a(\u79d2)\r\n        Map&lt;String, Long&gt; expires = new HashMap&lt;String, Long&gt;();\r\n        expires.put(\"cache.day\", new Long(24 * 60 * 60));\r\n        expires.put(\"cache.short\", new Long(3 * 60));\r\n        cacheManager.setExpires(expires);\r\n        return cacheManager;\r\n    }\r\n}  \r\n<\/code><\/pre>\n<h2>\u5e94\u7528\u65b9\u5f0f<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Cacheable\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3067\u30ad\u30e3\u30c3\u30b7\u30e5\u306b\u4e57\u305b\u308b\u3053\u3068\u304c\u53ef\u80fd\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">value\u5c5e\u6027\u306b\u306f\u4e0a\u306eexpires\u306b\u8a2d\u5b9a\u3057\u305f\u5024\u3092\u6307\u5b9a\u3059\u308b\u3068\u5c02\u7528\u306e\u6709\u52b9\u671f\u9650\u304c\u8a2d\u5b9a\u3055\u308c\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">expires\u306b\u5b58\u5728\u3057\u306a\u3044\u5024\u306b\u3059\u308b\u3068\u7121\u671f\u9650\uff08\u30c7\u30d5\u30a9\u30eb\u30c8\uff09\u306b\u306a\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">key\u5c5e\u6027\u306b\u306fredis\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u3068\u3057\u3066\u767b\u9332\u3057\u305f\u3044\u30ad\u30fc\u3092\u8a18\u8f09\u3059\u308b\u3002EL\u5f0f\u3092\u8a18\u8f09\u3059\u308b\u3053\u3068\u3067\u5f15\u6570\u306e\u5024\u3092\u542b\u3093\u3060\u30ad\u30fc\u3068\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/ul>\n<pre class=\"post-pre\"><code>  @Cacheable(value = \"cache.day\", key = \"'item\/' #itemId\")\r\n  public Item find(String itemId) {\r\n    \/\/ execute database sql\r\n  }\r\n<\/code><\/pre>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u3053\u306e\u4f8b\u3067\u306fvalue\u5c5e\u6027\u306bcache.day\u3092\u5229\u7528\u3057\u3066\u3044\u305f\u3081\u6709\u52b9\u671f\u9650(Redis\u306ettl)\u304c24\u6642\u9593\u3068\u306a\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u547c\u3073\u51fa\u3057\u5143\u304b\u3089find(&#8220;001&#8221;)\u3067\u30b3\u30fc\u30eb\u3057\u305f\u3068\u304dredis\u306b\u767b\u9332\u3055\u308c\u308bkey\u5024\u306f\u300citem\/001\u300d\u3068\u306a\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">item\/001\u306b\u5bfe\u3059\u308bvalue\u306fsqlTemplate.find(itemId)\u306e\u7d50\u679c\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u3042\u308bItem\u3092Serialize\u3057\u305f\u3082\u306e\u306b\u306a\u308b\u3002Serializer\u306fRedisTemplate\u306b\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u5909\u66f4\u53ef\u80fd\u3002<\/ul>\n<h2>\u5185\u90e8\u64cd\u4f5c<\/h2>\n<p>\u5177\u6709@Cacheable\u6ce8\u89e3\u7684\u65b9\u6cd5\u5c06\u53d7\u5230CacheInterceptor\u7684\u5904\u7406\u3002<br \/>\n\u4e0b\u56fe\u663e\u793a\u4e86\u8c03\u7528\u4e0a\u8ff0\u65b9\u6cd5\u65f6\u7684\u8fc7\u7a0b\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"RedisCache.001.png\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d3efd37434c4406c8ce16\/22-0.png\" alt=\"RedisCache.001.png\" \/><\/div>\n<pre class=\"post-pre\"><code>\u2460EXISTS cache.day~lock\r\n<\/code><\/pre>\n<p>\u8fd9\u662f\u4e00\u79cd\u7528\u4e8e\u89e3\u9501\u7684\u673a\u5236\u3002<br \/>\ncache.day~lock\u662f\u5728\u6267\u884cRedisCache#clean\u5904\u7406\u65f6\u521b\u5efa\u7684\u952e\uff0c\u53ea\u8981\u8be5\u952e\u5b58\u5728\uff0cRedisCache\u5c31\u4f1a\u7b49\u5f85\u3002<br \/>\n\u867d\u7136\u8bf4\u7b49\u5f85\uff0c\u4f46\u5176\u5b9e\u53ea\u662f\u5728\u8be5\u952e\u6d88\u5931\u4e4b\u524d\u6bcf300\u6beb\u79d2\u8fdb\u884c\u4e00\u6b21EXIST\u68c0\u67e5\u5faa\u73af\uff08\u5728spring data redis 1.6.0.RELEASE\u4e2d\u8fdb\u884c\u786e\u8ba4\uff09\u3002<\/p>\n<pre class=\"post-pre\"><code>\u2461GET item\/001\r\n<\/code><\/pre>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30ad\u30fc\u300citem\/001\u300d\u306b\u8a72\u5f53\u3059\u308b\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u7d50\u679c\u304c\u5b58\u5728\u3057\u306a\u3051\u308c\u3070\u3053\u3053\u3067@Cacheable\u3092\u4ed8\u4e0e\u3057\u305f\u30e1\u30bd\u30c3\u30c9\u304c\u547c\u3073\u51fa\u3055\u308c\u308b\u3002\u7a7a\u30c7\u30fc\u30bf\u3067\u3082\u30ad\u30fc\u304c\u5b58\u5728\u3059\u308c\u3070\u30e1\u30bd\u30c3\u30c9\u306f\u547c\u3073\u51fa\u3055\u308c\u306a\u3044\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u7d50\u679c\u304c\u5b58\u5728\u3057\u3066\u308c\u3070\u547c\u3073\u51fa\u3057\u5143\u306bRedis\u304b\u3089\u53d6\u5f97\u3057\u305f\u5024\u3092\u8fd4\u5374\u3057\u3066\u7d42\u4e86\u3002<\/ul>\n<pre class=\"post-pre\"><code>\u2463EXISTS cache.day~lock\r\n<\/code><\/pre>\n<p>\u5728\u8fdb\u884cSET\u64cd\u4f5c\u4e4b\u524d\uff0c\u4e0e\u6267\u884cGET\u64cd\u4f5c\u65f6\u4e00\u6837\uff0c\u9700\u8981\u786e\u8ba4\u9501\u7684\u72b6\u6001\u3002<\/p>\n<pre class=\"post-pre\"><code>\u2464MULTI\u301c\u2468EXEC\r\n<\/code><\/pre>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u958b\u59cb\u3057\u307e\u3059\u3002\u3053\u3053\u304b\u3089\u2468EXEC\u307e\u3067\u306f\u540c\u4e00\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u3067\u51e6\u7406\u3055\u308c\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u2465\u3067\u5024\u3092\u30bb\u30c3\u30c8\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u2466\u3067\u306fkey\u3092cache.day~keys\u3068\u3044\u3046SortedSet\u306b\u767b\u9332\u3002@Cacheable\u306evalue\u5024\u6bce\u306b\u30ad\u30fc\u306e\u4e00\u89a7\u3092\u7ba1\u7406\u3059\u308b\u5f62\u306b\u306a\u308b\u3002\u7d50\u679c\u3068\u3057\u3066\u6709\u52b9\u671f\u9650\u6bce\u306b\u30ad\u30fc\u306e\u4e00\u89a7\u304c\u7ba1\u7406\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u2467\u6709\u52b9\u671f\u9650\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308c\u3070EXPIRE\u30b3\u30de\u30f3\u30c9\u767a\u884c\u3002<\/ul>\n<h2>\u6e05\u9664\u7f13\u5b58<\/h2>\n<p>@CacheEvict\u3092\u4ed8\u4e0e\u3057\u305f\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3076\u3068DEL\u3059\u308b\u3002<br \/>\n\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3059\u308b\u3068value\u5c5e\u6027\u3092@Cacheable\u306evalue\u3068\u540c\u4e00\u306b\u3059\u308b\u3053\u3068\u3067\u5bfe\u5fdc\u3059\u308b\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u5168\u3066\u524a\u9664\u3067\u304d\u308b\u3002<\/p>\n<pre class=\"post-pre\"><code>@CacheEvict(value = \"cache.day\", allEntries = true)\r\npublic void evict() {\r\n    \/\/ delete DB data \r\n}\r\n<\/code><\/pre>\n<h2>\u5728Cache\u9519\u8bef\u53d1\u751f\u65f6\uff0c\u884c\u4e3a\u4f1a\u53d1\u751f\u53d8\u5316\u3002<\/h2>\n<p>\u901a\u8fc7\u5c06CacheErrorHandler\u6ce8\u518c\u4e3aBean\uff0c\u53ef\u4ee5\u5b9a\u4e49\u5728\u53d1\u751f\u4e0e\u7f13\u5b58\u76f8\u5173\u7684\u9519\u8bef\u65f6\u7684\u884c\u4e3a\u3002<\/p>\n<p>\u5c06Cache\u4e2d\u7684\u6240\u6709\u5f02\u5e38\u8bb0\u5f55\u5230\u65e5\u5fd7\u4e2d\uff0c\u65e0\u9700\u8ba9\u8c03\u7528\u65b9\u610f\u8bc6\u5230\u7531\u4e8e\u7f13\u5b58\u800c\u4ea7\u751f\u7684\u9519\u8bef\uff0c\u59cb\u7ec8\u8c03\u7528\u5e26\u6709@Cacheable\u6ce8\u89e3\u7684\u65b9\u6cd5\u7684\u793a\u4f8b\u3002<\/p>\n<pre class=\"post-pre\"><code>@Bean\r\n@Override\r\npublic CacheErrorHandler errorHandler() {\r\n  return new CacheErrorHandler() {\r\n    @Override\r\n    public void handleCacheGetError(RuntimeException exception, Cache cache, Object key) {\r\n      LOGGER.error(String.format(\"%s:%s:%s\", cache.getName(), key, exception.getMessage()),\r\n            exception);\r\n    }\r\n\r\n    @Override\r\n    public void handleCachePutError(RuntimeException exception, Cache cache, Object key,\r\n          Object value) {\r\n      LOGGER.error(String.format(\"%s:%s:%s\", cache.getName(), key, exception.getMessage()),\r\n            exception);\r\n    }\r\n\r\n    @Override\r\n    public void handleCacheEvictError(RuntimeException exception, Cache cache, Object key) {\r\n        LOGGER.error(String.format(\"%s:%s:%s\", cache.getName(), key, exception.getMessage()),\r\n            exception);\r\n      LOGGER.error(exception.getMessage(), exception);\r\n    }\r\n\r\n    @Override\r\n    public void handleCacheClearError(RuntimeException exception, Cache cache) {\r\n      LOGGER.error(String.format(\"%s:%s\", cache.getName(), exception.getMessage()), exception);\r\n      LOGGER.error(exception.getMessage(), exception);\r\n    }\r\n  };\r\n}\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148\uff0c\u5148\u884c\u52a8 \u6dfb\u52a0\u4f9d\u5b58\u5173\u7cfb maven\u306e\u5834\u5408pom\u306bspring-boot-starter\u3068spring-bo [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-40233","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4f7f\u7528Spring Boot\u6765\u4f7f\u7528Spring Data Redis - Blog - Silicon Cloud<\/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.silicloud.com\/zh\/blog\/\u4f7f\u7528spring-boot\u6765\u4f7f\u7528spring-data-redis\u3002\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f7f\u7528Spring Boot\u6765\u4f7f\u7528Spring Data Redis\" \/>\n<meta property=\"og:description\" content=\"\u9996\u5148\uff0c\u5148\u884c\u52a8 \u6dfb\u52a0\u4f9d\u5b58\u5173\u7cfb maven\u306e\u5834\u5408pom\u306bspring-boot-starter\u3068spring-bo [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528spring-boot\u6765\u4f7f\u7528spring-data-redis\u3002\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-12-06T01:00:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-29T07:40:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d3efd37434c4406c8ce16\/22-0.png\" \/>\n<meta name=\"author\" content=\"\u9038, \u79d1\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u9038, \u79d1\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8spring-boot%e6%9d%a5%e4%bd%bf%e7%94%a8spring-data-redis%e3%80%82\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8spring-boot%e6%9d%a5%e4%bd%bf%e7%94%a8spring-data-redis%e3%80%82\/\",\"name\":\"\u4f7f\u7528Spring Boot\u6765\u4f7f\u7528Spring Data Redis - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-12-06T01:00:43+00:00\",\"dateModified\":\"2024-04-29T07:40:50+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/85c1dae56e6ea1e695c73d33c684d487\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8spring-boot%e6%9d%a5%e4%bd%bf%e7%94%a8spring-data-redis%e3%80%82\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8spring-boot%e6%9d%a5%e4%bd%bf%e7%94%a8spring-data-redis%e3%80%82\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8spring-boot%e6%9d%a5%e4%bd%bf%e7%94%a8spring-data-redis%e3%80%82\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f7f\u7528Spring Boot\u6765\u4f7f\u7528Spring Data Redis\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/85c1dae56e6ea1e695c73d33c684d487\",\"name\":\"\u9038, \u79d1\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c94f6d9cbbfbca863fab309840bd690c153c95f8490c290ad2ed54dd693dad16?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c94f6d9cbbfbca863fab309840bd690c153c95f8490c290ad2ed54dd693dad16?s=96&d=mm&r=g\",\"caption\":\"\u9038, \u79d1\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/keyi\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8spring-boot%e6%9d%a5%e4%bd%bf%e7%94%a8spring-data-redis%e3%80%82\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u4f7f\u7528Spring Boot\u6765\u4f7f\u7528Spring Data Redis - Blog - Silicon Cloud","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.silicloud.com\/zh\/blog\/\u4f7f\u7528spring-boot\u6765\u4f7f\u7528spring-data-redis\u3002\/","og_locale":"zh_CN","og_type":"article","og_title":"\u4f7f\u7528Spring Boot\u6765\u4f7f\u7528Spring Data Redis","og_description":"\u9996\u5148\uff0c\u5148\u884c\u52a8 \u6dfb\u52a0\u4f9d\u5b58\u5173\u7cfb maven\u306e\u5834\u5408pom\u306bspring-boot-starter\u3068spring-bo [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528spring-boot\u6765\u4f7f\u7528spring-data-redis\u3002\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-12-06T01:00:43+00:00","article_modified_time":"2024-04-29T07:40:50+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d3efd37434c4406c8ce16\/22-0.png"}],"author":"\u9038, \u79d1","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u9038, \u79d1","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8spring-boot%e6%9d%a5%e4%bd%bf%e7%94%a8spring-data-redis%e3%80%82\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8spring-boot%e6%9d%a5%e4%bd%bf%e7%94%a8spring-data-redis%e3%80%82\/","name":"\u4f7f\u7528Spring Boot\u6765\u4f7f\u7528Spring Data Redis - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-12-06T01:00:43+00:00","dateModified":"2024-04-29T07:40:50+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/85c1dae56e6ea1e695c73d33c684d487"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8spring-boot%e6%9d%a5%e4%bd%bf%e7%94%a8spring-data-redis%e3%80%82\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8spring-boot%e6%9d%a5%e4%bd%bf%e7%94%a8spring-data-redis%e3%80%82\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8spring-boot%e6%9d%a5%e4%bd%bf%e7%94%a8spring-data-redis%e3%80%82\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u4f7f\u7528Spring Boot\u6765\u4f7f\u7528Spring Data Redis"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/85c1dae56e6ea1e695c73d33c684d487","name":"\u9038, \u79d1","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c94f6d9cbbfbca863fab309840bd690c153c95f8490c290ad2ed54dd693dad16?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c94f6d9cbbfbca863fab309840bd690c153c95f8490c290ad2ed54dd693dad16?s=96&d=mm&r=g","caption":"\u9038, \u79d1"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/keyi\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8spring-boot%e6%9d%a5%e4%bd%bf%e7%94%a8spring-data-redis%e3%80%82\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/40233","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=40233"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/40233\/revisions"}],"predecessor-version":[{"id":86156,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/40233\/revisions\/86156"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=40233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=40233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=40233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}