In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces you to the example analysis of Spring Data Redis, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Spring Data Redis introduction
Spring-Data-Redis is a part of the Spring family, which provides access to Redis services through simple configuration in Spring applications, and highly encapsulates the underlying Redis development packages (Jedis, JRedis, Redisson). RedisTemplate provides a variety of Redis operations, exception handling and serialization, and supports publish and subscribe. Spring-Data-Redis provides the following features for jedis:
Automatic connection pool management, providing a highly encapsulated "RedisTemplate" class
A large number of api in jedis client are classified and encapsulated, and the same type of operation is encapsulated as operation API as follows:
ValueOperations: simple Kmurv operation
SetOperations: set type data operation
ZSetOperations: zset type data operation
HashOperations: data manipulation of hash type
ListOperations: data manipulation of list type
Brief introduction of Redis data structure
Redis can store the mapping between keys and five different types of data structures, namely String (string), List (list), Set (collection), Hash (hash), and Zset (ordered set).
RedisTemplate introduction
Spring encapsulates RedisTemplate objects to perform various operations on Redis, and it supports all Redis native api. RedisTemplate is located under the spring-data-redis package.
The structure of RedisTemplate in Spring code is as follows:
Org.springframework.data.redis.coreClass RedisTemplatejava.lang.Object org.springframework.data.redis.core.RedisAccessor org.springframework.data.redis.core.RedisTemplate
Type Parameters:
K
The type of Redis key in the template (usually String) such as: RedisTemplate Note: if there is no special case, do not define as RedisTemplate, otherwise according to the Richter scale replacement principle, it will cause type errors when used.
V
The type of Redis value in the template
StringRedisTemplate and RedisTemplate
The relationship between the two is that StringRedisTemplate inherits RedisTemplate.
The data of the two are not in common; that is, StringRedisTemplate can only manage the data in StringRedisTemplate, and RedisTemplate can only manage the data in RedisTemplate.
There are two kinds of serialization strategies adopted by SDR by default, one is the serialization strategy of String and the other is the serialization strategy of JDK. StringRedisTemplate defaults to the serialization strategy of String, and the saved key and value are serialized and saved using this policy. RedisTemplate defaults to the serialization strategy of JDK, and the saved key and value are serialized and saved using this policy.
Spring Data Redis use case
This is the end of the sample analysis on Spring Data Redis. I hope the above content can be of some help to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.