数据库
首页 > 数据库> > redis应用详解

redis应用详解

作者:互联网

1、redis的5种数据结构类型:String(字符串)、Hash(哈希)、List(列表)、Set(集合)、Zset(有序集合)、

1.1 、String(字符串)

常用方法:

调用打印结果

 

1.2、Hash(哈希)

 

常用方法:

//操作hash
        HashOperations<String, String, String> hashOperations = redisTemplate
                .opsForHash();
        hashOperations.put("hashKey", "hashKey1", "hashValue1");
        hashOperations.put("hashKey", "hashKey2", "hashValue2");
        hashOperations.put("hashKey", "hashKey3", "hashValue3");
        logger.info("哈希put操作后,根据key值:hashKey,获取的所有hashKey值为"
                + hashOperations.keys("hashKey"));
        logger.info("哈希put操作后,根据key值:hashKey,获取的所有hashValue值为"
                + hashOperations.values("hashKey"));
        logger.info("哈希put操作后,根据key值:hashKey,获取的hashValue值为"
                + hashOperations.get("hashKey", "hashKey1"));
        hashOperations.getOperations().delete("hashKey");
        logger.info("哈希delete操作后,根据key值:hashKey,获取的hashValue值为"
                + hashOperations.get("hashKey", "hashKey1"));

调用打印结果

 

 

 

 

 

 1.3、 List(列表)

标签:hashOperations,应用,值为,redis,hashKey,详解,key,哈希,logger
来源: https://www.cnblogs.com/lchzlp/p/11518590.html