Official website: http://projects.spring.io/spring-data-redis/First step: Import dependent packages in Pom.xml12xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >34 56789 Ten One//maven.apache.org A - - the - - - + - + A at - - - - - in - to + - the * $ Panax Notoginseng -Step Two: Configure Jedis, inside the Application.xml(Note
OverviewRedisTemplateThe default is to use a serializer based on JDK , so the data stored in if it is Redis not deserialized, see the result is like this:Can see, there is garbled, at the program level, will not affect the operation of the program, but when the data errors, the data to troubleshoot, will not be able to.SerializerIn spring Data Redis, the conversi
Using the underlying API: RedisConnection operation of Redis requires manual conversion of data ( String ), which requires most repetitive work and is inefficient; org.springframework.data.redis.core.RedisTemplate classes provide a high level of abstraction for interacting with Redis, which is responsible for serialization and connection management, encapsulating most of the repetitive work. And RedisTempl
In the near term, the company took over a order number generation service, the rules have been set by the project manager, they are the main number of the following four-digit representative of the current order number has been executed the first few. And there is a requirement to support the distributed. In order to achieve this, I started using Redis's incr to solve this problem, because our backend development uses spring boot, so I found a code li
Redis is a very good caching framework, good API, strong performance, is now very very fire caching framework. Here's how to integrate Redis in springAnalysis:
Need to introduce dependency
You need to configure the connection pool, which is an XML file, and then the parameters are written in the properties
Need to write a tool class, the main method is to get
The above two introduces the configuration of the Redis cluster with some basic concepts, so of course it is to be used in the project, Redis Java support has done very well, so we try to use these APIs for Redis operations, first we need to operate Redis's rack package: 2.7. 3All we need to do is inject these basic classes into the
The above two introduces the configuration of the Redis cluster with some basic concepts, so of course it is to be used in the project, Redis Java support has done very well, so we try to use these APIs for Redis operations, first we need to operate Redis's rack package: All we need to do is inject these basic classes into the
(redisNode7001); Redisclusterconfiguration.addclusternode (redisNode7002); Redisclusterconfiguration.addclusternode (redisNode7003); Redisclusterconfiguration.addclusternode (redisNode7004); Redisclusterconfiguration.addclusternode (redisNode7005); ConnectionFactory = new JedisconnecTionfactory (redisclusterconfiguration); Set the connection pool configuration connectionfactory.setpoolconfig (Jedisconfig ()); Set the database, default 0 connectionfactory.setdatabase (2); Set use C
Jedis,spring-redis-data integration, when the version mismatch, often reported some exceptions, such as1:java.lang.noclassdeffounderror:org/springframework/data/geo/metric2:java.lang.nosuchmethoderror:redis.clients.jedis.jediscluster.set ([b[b) ljava/lang/string3:jedis.exceptions.jedisconnectionexception:unknown Reply:3are caused by Jedis,spring-
>springsessionrepositoryfilterfilter-name> filter-class> Org.springframework.web.filter.delegatingfilterproxy Filter-class>filter>filter-mapping> filter-name> Springsessionrepositoryfilterfilter-name> url-pattern>/*url-pattern>filter-mapping> 3. Using Spring-sessionAs long as the session is invoked using the standard Servlet API, it will be available at the bottom of the spring session and will be stored i
first, and after close () calls the Close () method, which is equivalent to generating a new session instance, so we do not have to manually close the session (), It is also not possible to use MyBatis's first-level cache, which means that MyBatis's first-level cache does not work in spring.
Therefore, we generally implement the MyBatis level two cache in the project, although MyBatis comes with a level two cache function, but if the actual cluster e
In Spring Data Redis 1.x , we might write such a redisconfig class in the project:@Configuration @enablecaching Public classRedisconfig {@SuppressWarnings ({"Rawtypes", "unchecked"}) @Bean (name= "Redistemplate") Publicredistemplate initredistemplate () {jedispoolconfig poolconfig=NewJedispoolconfig (); //Maximum idle numberPoolconfig.setmaxidle (50); //Maximum number of connectionsPoolconfig.setmaxtota
Using the underlying API: RedisConnectionFactory and RedisConnection You can manipulate Redis directly, here's a simple example:# # Maven DependencyConfigure Redis.propertiesredis.host=127.0.0.1redis.port=6379Configure Spring-data-redis.xmlOperating Redispublic static void main( String[] args ){ ApplicationContext context = new ClassPathXmlApplicationContext("classpath:spring-data-redis.xml"); //
Function Introduction
Most of the users like to use Redistemplate, and its corresponding package is org.springframework.data.redis.core. The template is actually the core class of the Redis module because of its rich functionality. Templates provide a high level of abstraction for redis interactions. Although Redisconnection provides a low-level way to accept and return binary values (byte arrays), the te
Spring-integrated Redis operations are almost always within the redistemplate.For example, Spring boot has beenConfiguration in Properties file againParameters for Redisspring.redis.host=127.0.0.1 spring.redis.port=6379 spring.redis.password=redispassspring.redis.database= 0spring.redis.timeout=5000Then add the following code to the application startup class:
Redis is operating in 1.spring, key is added and keys seen in the console are serialized2. As "\xac\xed\x00\x05t\x00\x12signrule2014-09-28", the actual key we added is signrule2014-09-283. Therefore, we cannot directly modify the value of the key with a script or command via a known key.4. You can use JSP to get or modify the value of Redis@page Import="org.sprin
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.