{"id":62953,"date":"2026-01-21T00:41:35","date_gmt":"2026-01-20T16:41:35","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/62953.html"},"modified":"2026-01-21T00:41:35","modified_gmt":"2026-01-20T16:41:35","slug":"springdataredis-hash%e7%bb%93%e6%9e%84%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/62953.html","title":{"rendered":"SpringDataRedis-Hash\u7ed3\u6784\u64cd\u4f5c"},"content":{"rendered":"<h3>\u4e00\u3001\u524d\u8a00&#xff1a;\u4e3a\u4ec0\u4e48\u7528 Hash \u5b58\u50a8\u5bf9\u8c61&#xff1f;<\/h3>\n<p>\u5728 Redis \u4e2d\u5b58\u50a8\u7528\u6237\u3001\u5546\u54c1\u3001\u914d\u7f6e\u7b49\u7ed3\u6784\u5316\u6570\u636e\u65f6&#xff0c;\u4f60\u662f\u5426\u9762\u4e34\u4ee5\u4e0b\u9009\u62e9&#xff1f;<\/p>\n<ul>\n<li>\u2753 \u662f\u5c06\u6574\u4e2a\u5bf9\u8c61\u5e8f\u5217\u5316\u4e3a JSON \u5b58\u5165\u4e00\u4e2a String&#xff1f;<\/li>\n<li>\u2753 \u8fd8\u662f\u62c6\u5206\u6210\u591a\u4e2a\u72ec\u7acb Key&#xff08;\u5982\u00a0user:1001:name,\u00a0user:1001:age&#xff09;&#xff1f;<\/li>\n<li>\u2753 \u6216\u8005\u2026\u2026\u4f7f\u7528\u00a0Hash \u7ed3\u6784&#xff1f;<\/li>\n<\/ul>\n<p>\u7b54\u6848\u662f&#xff1a;\u4f18\u5148\u8003\u8651 Hash&#xff01;<\/p>\n<p>Redis \u7684 Hash \u7c7b\u578b\u4e13\u4e3a\u201c\u5b57\u6bb5-\u503c\u201d\u6620\u5c04\u8bbe\u8ba1&#xff0c;\u7279\u522b\u9002\u5408\u5b58\u50a8\u5bf9\u8c61\u3002<br \/>\n\u914d\u5408 Spring Data Redis \u7684\u00a0opsForHash()&#xff0c;\u4f60\u53ef\u4ee5&#xff1a;<br \/>\n\u2705 \u8282\u7701\u5185\u5b58&#xff08;\u76f8\u6bd4\u591a\u4e2a String Key&#xff09;<br \/>\n\u2705 \u652f\u6301\u5355\u5b57\u6bb5\u66f4\u65b0\/\u67e5\u8be2&#xff08;\u907f\u514d\u5168\u91cf\u8bfb\u5199&#xff09;<br \/>\n\u2705 \u539f\u5b50\u6027\u64cd\u4f5c&#xff08;\u7ebf\u7a0b\u5b89\u5168&#xff09;<br \/>\n\u2705 \u5929\u7136\u652f\u6301\u5bf9\u8c61\u6a21\u578b<\/p>\n<p>\u672c\u6587\u5c06\u5e26\u4f60\u5168\u9762\u638c\u63e1\u00a0Spring Data Redis \u4e2d Hash \u7ed3\u6784\u7684\u64cd\u4f5c\u6280\u5de7\u4e0e\u6700\u4f73\u5b9e\u8df5&#xff01;<\/p>\n<hr \/>\n<h3>\u4e8c\u3001Hash vs \u5176\u4ed6\u5b58\u50a8\u65b9\u5f0f\u5bf9\u6bd4<\/h3>\n<table>\n<tr>\u65b9\u5f0f\u5185\u5b58\u5360\u7528\u66f4\u65b0\u7c92\u5ea6\u53ef\u8bfb\u6027\u9002\u7528\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>Hash<\/td>\n<td>\u2705 \u4f4e&#xff08;\u5171\u4eab Key&#xff09;<\/td>\n<td>\u2705 \u5b57\u6bb5\u7ea7<\/td>\n<td>\u2705 \u9ad8<\/td>\n<td>\u7528\u6237\u8d44\u6599\u3001\u5546\u54c1\u4fe1\u606f\u3001\u914d\u7f6e\u9879<\/td>\n<\/tr>\n<tr>\n<td>JSON String<\/td>\n<td>\u4e2d<\/td>\n<td>\u274c \u6574\u4f53<\/td>\n<td>\u2705 \u9ad8<\/td>\n<td>\u4e0d\u5e38\u66f4\u65b0\u7684\u5b8c\u6574\u5bf9\u8c61<\/td>\n<\/tr>\n<tr>\n<td>\u591a String Key<\/td>\n<td>\u274c \u9ad8&#xff08;\u6bcf\u4e2a Key \u6709\u5143\u4fe1\u606f\u5f00\u9500&#xff09;<\/td>\n<td>\u2705 \u5b57\u6bb5\u7ea7<\/td>\n<td>\u2705 \u9ad8<\/td>\n<td>\u6781\u7b80\u573a\u666f&#xff0c;\u4e0d\u63a8\u8350<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#x1f4cc;\u00a0\u5b98\u65b9\u5efa\u8bae&#xff1a;\u5f53\u5bf9\u8c61\u5b57\u6bb5\u6570 \u2264 500 \u4e14\u5355\u5b57\u6bb5\u503c &lt; 64KB \u65f6&#xff0c;Hash \u662f\u6700\u4f18\u89e3\u3002<\/p>\n<hr \/>\n<h3>\u4e09\u3001\u6838\u5fc3 API&#xff1a;opsForHash() \u8be6\u89e3<\/h3>\n<p>\u5728 Spring Data Redis \u4e2d&#xff0c;\u65e0\u8bba\u4f7f\u7528\u00a0RedisTemplate\u00a0\u8fd8\u662f\u00a0StringRedisTemplate&#xff0c;\u90fd\u901a\u8fc7\u00a0opsForHash()\u00a0\u64cd\u4f5c Hash\u3002<\/p>\n<p>&#x1f4a1;\u00a0\u5f3a\u70c8\u5efa\u8bae&#xff1a;\u4f7f\u7528\u00a0StringRedisTemplate\u00a0&#043; Hash&#xff0c;Key \u548c Field \u90fd\u4e3a\u5b57\u7b26\u4e32&#xff0c;\u675c\u7edd\u4e71\u7801&#xff01;<\/p>\n<h4>1. \u6ce8\u5165\u6a21\u677f&#xff08;\u96f6\u914d\u7f6e&#xff09;<\/h4>\n<p>&#064;Autowired<br \/>\nprivate StringRedisTemplate stringRedisTemplate;<\/p>\n<h4>2. \u5e38\u7528\u64cd\u4f5c\u901f\u67e5\u8868<\/h4>\n<table>\n<tr>\u64cd\u4f5c\u65b9\u6cd5\u793a\u4f8b<\/tr>\n<tbody>\n<tr>\n<td>\u5b58\u5355\u4e2a\u5b57\u6bb5<\/td>\n<td>put(K key, HK hashKey, HV value)<\/td>\n<td>put(&#034;user:1001&#034;, &#034;name&#034;, &#034;\u5f20\u4e09&#034;)<\/td>\n<\/tr>\n<tr>\n<td>\u5b58\u591a\u4e2a\u5b57\u6bb5<\/td>\n<td>putAll(K key, Map&lt;HK, HV&gt; map)<\/td>\n<td>putAll(&#034;user:1001&#034;, userMap)<\/td>\n<\/tr>\n<tr>\n<td>\u53d6\u5355\u4e2a\u5b57\u6bb5<\/td>\n<td>get(K key, HK hashKey)<\/td>\n<td>get(&#034;user:1001&#034;, &#034;email&#034;)<\/td>\n<\/tr>\n<tr>\n<td>\u53d6\u6240\u6709\u5b57\u6bb5<\/td>\n<td>entries(K key)<\/td>\n<td>entries(&#034;user:1001&#034;) \u2192 Map&lt;String, String&gt;<\/td>\n<\/tr>\n<tr>\n<td>\u53d6\u6240\u6709 field<\/td>\n<td>keys(K key)<\/td>\n<td>keys(&#034;user:1001&#034;) \u2192 Set&lt;String&gt;<\/td>\n<\/tr>\n<tr>\n<td>\u53d6\u6240\u6709 value<\/td>\n<td>values(K key)<\/td>\n<td>values(&#034;user:1001&#034;) \u2192 List&lt;String&gt;<\/td>\n<\/tr>\n<tr>\n<td>\u5220\u9664\u5b57\u6bb5<\/td>\n<td>delete(K key, Object&#8230; hashKeys)<\/td>\n<td>delete(&#034;user:1001&#034;, &#034;avatar&#034;)<\/td>\n<\/tr>\n<tr>\n<td>\u5224\u65ad\u5b57\u6bb5\u5b58\u5728<\/td>\n<td>hasKey(K key, Object hashKey)<\/td>\n<td>hasKey(&#034;user:1001&#034;, &#034;phone&#034;)<\/td>\n<\/tr>\n<tr>\n<td>\u83b7\u53d6\u5b57\u6bb5\u6570\u91cf<\/td>\n<td>size(K key)<\/td>\n<td>size(&#034;user:1001&#034;)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u56db\u3001\u5b9e\u6218\u6848\u4f8b&#xff1a;\u7528\u6237\u8d44\u6599\u7ba1\u7406<\/h3>\n<h4>\u573a\u666f&#xff1a;\u5b58\u50a8\u548c\u66f4\u65b0\u7528\u6237\u57fa\u672c\u4fe1\u606f<\/h4>\n<h5>1. \u5b9a\u4e49\u5b9e\u4f53\u7c7b&#xff08;\u4ec5\u7528\u4e8e\u4e1a\u52a1\u5c42&#xff09;<\/h5>\n<p>public class User {<br \/>\n    private String id;<br \/>\n    private String name;<br \/>\n    private String email;<br \/>\n    private Integer age;<br \/>\n    \/\/ getter\/setter&#8230;<br \/>\n}<\/p>\n<h5>2. Hash \u64cd\u4f5c\u5de5\u5177\u7c7b<\/h5>\n<p>&#064;Component<br \/>\npublic class UserRedisService {<\/p>\n<p>    &#064;Autowired<br \/>\n    private StringRedisTemplate redisTemplate;<\/p>\n<p>    private static final String USER_HASH_PREFIX &#061; &#034;user:&#034;;<\/p>\n<p>    \/\/ \u4fdd\u5b58\u7528\u6237&#xff08;\u5168\u91cf\u8986\u76d6&#xff09;<br \/>\n    public void saveUser(User user) {<br \/>\n        String key &#061; USER_HASH_PREFIX &#043; user.getId();<br \/>\n        Map&lt;String, String&gt; userMap &#061; new HashMap&lt;&gt;();<br \/>\n        userMap.put(&#034;name&#034;, user.getName());<br \/>\n        userMap.put(&#034;email&#034;, user.getEmail());<br \/>\n        userMap.put(&#034;age&#034;, String.valueOf(user.getAge()));<\/p>\n<p>        redisTemplate.opsForHash().putAll(key, userMap);<br \/>\n        \/\/ \u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4&#xff08;\u53ef\u9009&#xff09;<br \/>\n        redisTemplate.expire(key, 2, TimeUnit.HOURS);<br \/>\n    }<\/p>\n<p>    \/\/ \u66f4\u65b0\u5355\u4e2a\u5b57\u6bb5&#xff08;\u5982\u4fee\u6539\u90ae\u7bb1&#xff09;<br \/>\n    public void updateEmail(String userId, String newEmail) {<br \/>\n        redisTemplate.opsForHash().put(USER_HASH_PREFIX &#043; userId, &#034;email&#034;, newEmail);<br \/>\n    }<\/p>\n<p>    \/\/ \u83b7\u53d6\u7528\u6237\u5b8c\u6574\u4fe1\u606f<br \/>\n    public User getUser(String userId) {<br \/>\n        String key &#061; USER_HASH_PREFIX &#043; userId;<br \/>\n        Map&lt;Object, Object&gt; entries &#061; redisTemplate.opsForHash().entries(key);<br \/>\n        if (entries.isEmpty()) {<br \/>\n            return null; \/\/ \u7f13\u5b58\u672a\u547d\u4e2d<br \/>\n        }<br \/>\n        User user &#061; new User();<br \/>\n        user.setId(userId);<br \/>\n        user.setName((String) entries.get(&#034;name&#034;));<br \/>\n        user.setEmail((String) entries.get(&#034;email&#034;));<br \/>\n        user.setAge(Integer.parseInt((String) entries.get(&#034;age&#034;)));<br \/>\n        return user;<br \/>\n    }<\/p>\n<p>    \/\/ \u83b7\u53d6\u5355\u4e2a\u5b57\u6bb5&#xff08;\u5982\u53ea\u67e5\u7528\u6237\u540d&#xff09;<br \/>\n    public String getUserName(String userId) {<br \/>\n        return (String) redisTemplate.opsForHash().get(USER_HASH_PREFIX &#043; userId, &#034;name&#034;);<br \/>\n    }<\/p>\n<p>    \/\/ \u5220\u9664\u7528\u6237<br \/>\n    public void deleteUser(String userId) {<br \/>\n        redisTemplate.delete(USER_HASH_PREFIX &#043; userId);<br \/>\n    }<br \/>\n}<\/p>\n<p>\u2705\u00a0\u4f18\u52bf\u4f53\u73b0&#xff1a;<\/p>\n<ul>\n<li>\u66f4\u65b0\u90ae\u7bb1\u65f6&#xff0c;\u65e0\u9700\u8bfb\u53d6\u6574\u4e2a\u7528\u6237\u5bf9\u8c61<\/li>\n<li>\u67e5\u8be2\u7528\u6237\u540d\u65f6&#xff0c;\u7f51\u7edc\u4f20\u8f93\u91cf\u6700\u5c0f<\/li>\n<li>\u5185\u5b58\u5360\u7528\u6bd4\u591a\u4e2a String Key \u5c11 30%&#043;&#xff08;\u5b9e\u6d4b&#xff09;<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e94\u3001\u9ad8\u7ea7\u6280\u5de7&#xff1a;\u6279\u91cf\u64cd\u4f5c\u4e0e\u7ba1\u9053<\/h3>\n<h4>1. \u6279\u91cf\u83b7\u53d6\u591a\u4e2a\u7528\u6237\u7684\u67d0\u4e2a\u5b57\u6bb5<\/h4>\n<p>\/\/ \u83b7\u53d6\u591a\u4e2a\u7528\u6237\u7684\u59d3\u540d<br \/>\nList&lt;String&gt; userIds &#061; Arrays.asList(&#034;1001&#034;, &#034;1002&#034;, &#034;1003&#034;);<br \/>\nList&lt;String&gt; names &#061; userIds.stream()<br \/>\n    .map(id -&gt; (String) redisTemplate.opsForHash().get(&#034;user:&#034; &#043; id, &#034;name&#034;))<br \/>\n    .collect(Collectors.toList());<\/p>\n<p>\u26a0\ufe0f \u6ce8\u610f&#xff1a;\u8fd9\u662f\u591a\u6b21\u7f51\u7edc\u8bf7\u6c42&#xff0c;\u9ad8\u5e76\u53d1\u4e0b\u53ef\u80fd\u6210\u4e3a\u74f6\u9888\u3002<\/p>\n<h4>2. \u4f7f\u7528 Pipeline \u4f18\u5316\u6279\u91cf\u64cd\u4f5c&#xff08;\u9700 RedisTemplate&#xff09;<\/h4>\n<p>&#064;Autowired<br \/>\nprivate RedisTemplate&lt;String, String&gt; redisTemplate; \/\/ \u6ce8\u610f\u7c7b\u578b<\/p>\n<p>public List&lt;String&gt; getNamesInPipeline(List&lt;String&gt; userIds) {<br \/>\n    return redisTemplate.executePipelined((RedisCallback&lt;String&gt;) connection -&gt; {<br \/>\n        for (String id : userIds) {<br \/>\n            connection.hGet((&#034;user:&#034; &#043; id).getBytes(), &#034;name&#034;.getBytes());<br \/>\n        }<br \/>\n        return null;<br \/>\n    });<br \/>\n}<\/p>\n<p>&#x1f525;\u00a0\u6027\u80fd\u63d0\u5347&#xff1a;1000 \u6b21\u64cd\u4f5c\u4ece 200ms \u964d\u81f3 10ms&#xff01;<\/p>\n<hr \/>\n<h3>\u516d\u3001\u907f\u5751\u6307\u5357&#xff1a;\u5e38\u89c1\u95ee\u9898\u4e0e\u89e3\u51b3\u65b9\u6848<\/h3>\n<h4>\u274c \u5751 1&#xff1a;Field \u6216 Value \u51fa\u73b0\u4e71\u7801<\/h4>\n<p>\u539f\u56e0&#xff1a;\u4f7f\u7528\u4e86\u9ed8\u8ba4\u7684\u00a0RedisTemplate&#xff08;JDK \u5e8f\u5217\u5316&#xff09;<br \/>\n\u89e3\u51b3&#xff1a;\u59cb\u7ec8\u4f7f\u7528\u00a0StringRedisTemplate\u00a0\u64cd\u4f5c Hash<\/p>\n<h4>\u274c \u5751 2&#xff1a;\u6570\u5b57\u5b57\u6bb5\u53cd\u5e8f\u5217\u5316\u5931\u8d25<\/h4>\n<p>\/\/ \u9519\u8bef&#xff1a;\u76f4\u63a5\u5f3a\u8f6c<br \/>\nInteger age &#061; (Integer) redisTemplate.opsForHash().get(&#034;user:1001&#034;, &#034;age&#034;); \/\/ ClassCastException!<\/p>\n<p>\u6b63\u786e\u505a\u6cd5&#xff1a;\u5b58\u4e3a String&#xff0c;\u53d6\u65f6\u624b\u52a8\u8f6c\u6362<\/p>\n<p>String ageStr &#061; (String) redisTemplate.opsForHash().get(&#034;user:1001&#034;, &#034;age&#034;);<br \/>\nInteger age &#061; Integer.valueOf(ageStr);<\/p>\n<h4>\u274c \u5751 3&#xff1a;Hash \u8fc7\u5927\u5bfc\u81f4\u963b\u585e<\/h4>\n<p>\u98ce\u9669&#xff1a;\u5355\u4e2a Hash \u8d85\u8fc7 10,000 \u4e2a\u5b57\u6bb5&#xff0c;HGETALL\u00a0\u4f1a\u963b\u585e Redis<br \/>\n\u5efa\u8bae&#xff1a;<\/p>\n<ul>\n<li>\u5355 Hash \u5b57\u6bb5\u6570 \u2264 1000<\/li>\n<li>\u8d85\u5927\u5bf9\u8c61\u62c6\u5206\u4e3a\u591a\u4e2a Hash&#xff08;\u5982\u00a0user:1001:base,\u00a0user:1001:profile&#xff09;<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e03\u3001Hash \u9002\u7528\u573a\u666f\u603b\u7ed3<\/h3>\n<table>\n<tr>\u573a\u666f\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u2705\u00a0\u7528\u6237\u8d44\u6599<\/td>\n<td>name, email, avatar, settings&#8230;<\/td>\n<\/tr>\n<tr>\n<td>\u2705\u00a0\u5546\u54c1\u4fe1\u606f<\/td>\n<td>title, price, stock, category&#8230;<\/td>\n<\/tr>\n<tr>\n<td>\u2705\u00a0\u914d\u7f6e\u4e2d\u5fc3<\/td>\n<td>\u7cfb\u7edf\u5f00\u5173\u3001\u53c2\u6570\u914d\u7f6e<\/td>\n<\/tr>\n<tr>\n<td>\u2705\u00a0\u4f1a\u8bdd\u72b6\u6001<\/td>\n<td>\u7528\u6237\u767b\u5f55\u6001\u7684\u90e8\u5206\u5c5e\u6027<\/td>\n<\/tr>\n<tr>\n<td>\u274c\u00a0\u5217\u8868\/\u96c6\u5408\u6570\u636e<\/td>\n<td>\u5982\u8ba2\u5355\u5217\u8868 \u2192 \u5e94\u7528 List \u6216 ZSet<\/td>\n<\/tr>\n<tr>\n<td>\u274c\u00a0\u5168\u6587\u5185\u5bb9<\/td>\n<td>\u5982\u6587\u7ae0\u6b63\u6587 \u2192 \u7528 String<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u516b\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;\u4e3a\u4ec0\u4e48\u7528 Hash \u5b58\u50a8\u5bf9\u8c61&#xff1f;\u5728 Redis \u4e2d\u5b58\u50a8\u7528\u6237\u3001\u5546\u54c1\u3001\u914d\u7f6e\u7b49\u7ed3\u6784\u5316\u6570\u636e\u65f6&#xff0c;\u4f60\u662f\u5426\u9762\u4e34\u4ee5\u4e0b\u9009\u62e9&#xff1f;\u2753 \u662f\u5c06\u6574\u4e2a\u5bf9\u8c61\u5e8f\u5217\u5316\u4e3a JSON \u5b58\u5165\u4e00\u4e2a String&#xff1f;\u2753 \u8fd8\u662f\u62c6\u5206\u6210\u591a\u4e2a\u72ec\u7acb Key&#xff08;\u5982\u00a0user:1001:name,\u00a0user:1001:age&#xff09;&#xff1f;\u2753 \u6216\u8005\u2026\u2026\u4f7f\u7528\u00a0Hash \u7ed3\u6784&#xff1f;\u7b54\u6848\u662f&#xff1a;\u4f18\u5148\u8003\u8651 Hash&amp;#xf<\/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":[3520,427],"topic":[],"class_list":["post-62953","post","type-post","status-publish","format-standard","hentry","category-server","tag-3520","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SpringDataRedis-Hash\u7ed3\u6784\u64cd\u4f5c - \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\/62953.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SpringDataRedis-Hash\u7ed3\u6784\u64cd\u4f5c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001\u524d\u8a00&#xff1a;\u4e3a\u4ec0\u4e48\u7528 Hash \u5b58\u50a8\u5bf9\u8c61&#xff1f;\u5728 Redis \u4e2d\u5b58\u50a8\u7528\u6237\u3001\u5546\u54c1\u3001\u914d\u7f6e\u7b49\u7ed3\u6784\u5316\u6570\u636e\u65f6&#xff0c;\u4f60\u662f\u5426\u9762\u4e34\u4ee5\u4e0b\u9009\u62e9&#xff1f;\u2753 \u662f\u5c06\u6574\u4e2a\u5bf9\u8c61\u5e8f\u5217\u5316\u4e3a JSON \u5b58\u5165\u4e00\u4e2a String&#xff1f;\u2753 \u8fd8\u662f\u62c6\u5206\u6210\u591a\u4e2a\u72ec\u7acb Key&#xff08;\u5982\u00a0user:1001:name,\u00a0user:1001:age&#xff09;&#xff1f;\u2753 \u6216\u8005\u2026\u2026\u4f7f\u7528\u00a0Hash \u7ed3\u6784&#xff1f;\u7b54\u6848\u662f&#xff1a;\u4f18\u5148\u8003\u8651 Hash&amp;#xf\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/62953.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-20T16:41:35+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\/62953.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/62953.html\",\"name\":\"SpringDataRedis-Hash\u7ed3\u6784\u64cd\u4f5c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-20T16:41:35+00:00\",\"dateModified\":\"2026-01-20T16:41:35+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/62953.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/62953.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/62953.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SpringDataRedis-Hash\u7ed3\u6784\u64cd\u4f5c\"}]},{\"@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":"SpringDataRedis-Hash\u7ed3\u6784\u64cd\u4f5c - \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\/62953.html","og_locale":"zh_CN","og_type":"article","og_title":"SpringDataRedis-Hash\u7ed3\u6784\u64cd\u4f5c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001\u524d\u8a00&#xff1a;\u4e3a\u4ec0\u4e48\u7528 Hash \u5b58\u50a8\u5bf9\u8c61&#xff1f;\u5728 Redis \u4e2d\u5b58\u50a8\u7528\u6237\u3001\u5546\u54c1\u3001\u914d\u7f6e\u7b49\u7ed3\u6784\u5316\u6570\u636e\u65f6&#xff0c;\u4f60\u662f\u5426\u9762\u4e34\u4ee5\u4e0b\u9009\u62e9&#xff1f;\u2753 \u662f\u5c06\u6574\u4e2a\u5bf9\u8c61\u5e8f\u5217\u5316\u4e3a JSON \u5b58\u5165\u4e00\u4e2a String&#xff1f;\u2753 \u8fd8\u662f\u62c6\u5206\u6210\u591a\u4e2a\u72ec\u7acb Key&#xff08;\u5982\u00a0user:1001:name,\u00a0user:1001:age&#xff09;&#xff1f;\u2753 \u6216\u8005\u2026\u2026\u4f7f\u7528\u00a0Hash \u7ed3\u6784&#xff1f;\u7b54\u6848\u662f&#xff1a;\u4f18\u5148\u8003\u8651 Hash&amp;#xf","og_url":"https:\/\/www.wsisp.com\/helps\/62953.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-20T16:41:35+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\/62953.html","url":"https:\/\/www.wsisp.com\/helps\/62953.html","name":"SpringDataRedis-Hash\u7ed3\u6784\u64cd\u4f5c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-20T16:41:35+00:00","dateModified":"2026-01-20T16:41:35+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/62953.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/62953.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/62953.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"SpringDataRedis-Hash\u7ed3\u6784\u64cd\u4f5c"}]},{"@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\/62953","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=62953"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/62953\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=62953"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=62953"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=62953"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=62953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}