Environmental requirements: Redis 2.6 and above, javase 8.0 and above;First, Spring Data Redis IntroductionSpring-data-redis is part of spring and provides a simple configuration to access the Redis service in the srping applicati
Http://www.open-open.com/lib/view/open1436322883958.htmlOne:Create a new Maven WebApp project and join the dependencies of spring sessionPom.xml as follows:Two:Configuring the Redis Environment1: Install Redis, start2:Package Com.lala.config;import Org.springframework.context.annotation.bean;import Org.springframework.data.redis.connection.jedis.jedisconnectionfa
Picture because the file is relatively large, commonly used pictures such as reading the database or file to increase the system load. The use of caching methods can increase efficiency.
Http://stackoverflow.com/questions/13215024/weird-redis-key-with-spring-data-jedis here has provided a picture of the reading method and type conversion method, can be modified.
In this paper, the files under the project ar
Then the previous blog: Spring boot integrated Jpa,shiro for Rights management
Shiro By default integrates the Ehcache to implement caching, if we want to use Redis to replace the Ehcache to implement the cache. We can find some clues from the source code of Shiro. We can simulate how ehcachemanager is implemented, and the Ehcachemanager class is defined as follows:
public class Ehcachemanager implements C
) {
shardinfo = new Jedisshardinfo (hostName, port);
if (stringutils.haslength (password)) {
Shardinfo.setpassword (password);
}
if (Timeout > 0) {
Settimeouton (shardinfo, timeout);
}
}
if (usepool) {
This.pool = CreatePool ();
}
}
This method will be invoked after all properties have been initialized. But it will be called before Init. Is the method of Initializingbean interfaces in spring. The
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
Just say the question.Dependency Packages: Jedis 2.9.0, Spring-data-reids 1.4.1Tip: Redis.clients.jedis.JedisShardInfo.setTimeout (I) V not found.Reason:Seemingly Jedis 2.6.2 after the Jedisshardinfo class "timeout" parameter changed to "SoTimeout". So when the integration of 2.9.0 will appear the above error.Workaround:Check the source on GitHub and find that the "timeout" parameter in the Jedisshardinfo class has been changed from jedis2.6.2 to "SoT
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-
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"); //
Redis a master multi-slave spring configuration
public class redistest{private ApplicationContext context;
Private Redistemplate redistemplate;
Final String key = "Key7";
@Before public void init () {context = new Classpathxmlapplicationcontext ("Applicationcontext.xml");
Redistemplate= Context.getbean ("Redistemplate", Redistemplate.class);
} @Test public void Test1
The front desk's product data (images and other slow loading) queries, first querying data from the Redis cache.Redis is a NoSQL database, Memory Edition database, read Speed 11w/s. itself has a memory-elimination mechanism, is a single-threaded server (time-sharing operating system), thread safety.Redis installation in Linux (standalone version): make;;Modify for background start;View process;Virtual machine Simulation of
The idea of using Redis as a cache is to configure the interceptor in the spring project, make slices on the service layer, and intercept on methods such as FINDXXX or getxxx to determine if caching is possible.1. Environment: Spring 3.1.2 + Spring data redis 1.0.0+ Jedis 2.
The Redis server can implement a simple message "Publish/subscribe" service, the following is a description of the Spring-redis implementation
Spring-redis use Redismessagelistenercontainer for message monitoring, client programs need to implement their own messagelistener,
I. SSM project-Distributed project Structure setup
Two. SSM Project-spring mybatis MySQL configuration implementation three SSM project-redis cache strategy and configuration implementation four. SSM Project-SPRINGMVC Configuration implementation
First, the SSM Framework Web project starts from the zero--distributed project structure constructs
/**
This article is the main original article, such as reprin
Redis is a non-relational database, and unlike MongoDB, Redis is a memory database, so access is fast. Commonly used as a cache and publish-subscribe message queue. The Redis official does not provide the Windows version of the software. The Windows version has been maintained by Microsoft.
Download Address: https://github.com/MSOpenTech/
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.