简体   繁体   English

Redis:将哈希映射存储在集合中

[英]Redis: Storing a hash map in a set

I'm using Jedis to store some documents on Redis .我正在使用JedisRedis上存储一些文档。 I have the following class:我有以下课程:

public class Document{
      public String id;
      public String title;
      public Map<String, Keyword> keywords = new HashMap<>();
  }

I used sadd to add a set to Redis.我使用sadd向 Redis 添加了一个集合。 I tried the following code:我尝试了以下代码:

Document d = new Document();
jedis.sadd(d.id,d.title);

But I don't know how to add the map in the set.但是我不知道如何在集合中添加地图。

The basic approach, afaik, is to serialize the map before adding it to the set. afaik 的基本方法是在将地图添加到集合之前对其进行序列化。 Note that Redis' sets are made of unique members, where each member is a string value (byte stream in the Java world iirc).请注意,Redis 的集合由唯一成员组成,其中每个成员都是一个字符串值(Java 世界 iirc 中的字节流)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM