Jedis jedis =
new
Jedis(
"127.0.0.1"
,6379);
Map<String, String> map =
new
HashMap<String,String>();
final
String USER_TABLE =
"USER_TABLE"
;
final
String USER_TABLE_AGE_15 =
"USER_TABLE_AGE_15"
;
final
String USER_TABLE_SEX_m =
"USER_TABLE_SEX_m"
;
final
String USER_TABLE_SEX_n =
"USER_TABLE_SEX_n"
;
String uuid1 = UUID.randomUUID().toString();
User user1 =
new
User(uuid1,
"y1"
,
"m"
, 15);
map.put(uuid1, JSONObject.fromObject(user1).toString());
jedis.sadd(USER_TABLE_AGE_15,uuid1);
jedis.sadd(USER_TABLE_SEX_m,uuid1);
String uuid2 = UUID.randomUUID().toString();
User user2 =
new
User(uuid2,
"y2"
,
"m"
, 18);
map.put(uuid2, JSONObject.fromObject(user2).toString());
jedis.sadd(USER_TABLE_SEX_m,uuid2);
String uuid3 = UUID.randomUUID().toString();
User user3 =
new
User(uuid3,
"y3"
,
"n"
, 25);
map.put(uuid3, JSONObject.fromObject(user3).toString());
String uuid4 = UUID.randomUUID().toString();
User user4 =
new
User(uuid4,
"y4"
,
"n"
, 15);
map.put(uuid4, JSONObject.fromObject(user4).toString());
jedis.sadd(USER_TABLE_AGE_15,uuid4);
String uuid5 = UUID.randomUUID().toString();
User user5 =
new
User(uuid5,
"y5"
,
"m"
, 25);
map.put(uuid5, JSONObject.fromObject(user5).toString());
jedis.sadd(USER_TABLE_SEX_m,uuid5);
jedis.hmset(
"USER_TABLE"
, map);