redis存储对象两种方式对比

redis存储对象结构的两种方式

  • 使用redis string结构存储对象序列化后的数据
  • 使用redis hash结构存储对象,field为字段名称

测试例子还是大家喜欢的用户信息

public class Customer {
    private long id;
    private String nickName;
    private String mobile;
    private String password;
    private int age;
    private String realName;
    private int sex;//-1:保密;0:女;1:男
}

测试结果:


结果分析:

从结果来看,redis hash结构在组织数据和占用内存方面占优,redis读取差别不大

猜你喜欢

转载自blog.csdn.net/weixin_42463676/article/details/80808150