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/redis/releases.
This is a redis-related tutorial. http://muxiulin.cn/archives/1197
The integration of Redis in spring is simple, with projects built with the SSM framework +maven.
The first is the Pom.xml file that needs to be introduced:
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" > <modelVersion>4.0.0</modelVersion> <groupid>ssmredisdemo</groupid > <artifactId>SSMRedisDemo</artifactId> <packaging>war</ packaging> <version>0.0.1-SNAPSHOT</version> <name>ssmredisdemo Maven webapp</name> <url>http://maven.apache.org</url> <properties
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <spring.version>4.2.0.RELEASE</spring.version> </properties > <dependencies> <!--spring MVC related... start-<!--Todo:replace Jackson with Fastjson- <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${ spring.version}</version> </dependency> < dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> &NB Sp <version>${spring.version}</version> </dependency> & nbsp <dependency> <groupId>org.springframework</groupId> <artifactid>spring-webmvc</artifactid> <version>${spring.version }</version> </dependency> <dependency> &
nbsp <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> &L t;version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework< /groupid> <artifactId>spring-web</artifactId> & nbsp <version>${spring.version}</version> </dependency> & nbsp <dependency> <groupId>javax.servlet</groupId> &N Bsp <artifactId>jstl</artifactId> <version>1.2</ version> </dependency> <dependency> (+) nbsp <groupId>commons-logging</groupId> < artifactid>commons-logging</artifactid> <version>1.1.3</ version> </dependency> <dependency> (+) nbsp <groupId>org.codehaus.jackson</groupId> < artifactid>jackson-mapper-asl</artifactid> <version>1.9.13 </version>   </dependency> <dependency> <GROUPID&G t;com.fasterxml.jackson.core</groupid> <artifactId>
jackson-annotations</artifactid> <version>2.6.1</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> < artifactid>jackson-core</artifactid> <version>2.6.1</ version> </dependency> <dependency> (+) nbsp <groupId>com.fasterxml.jackson.core</groupId> <ARTIFACTID>JACKSON-DATABIND</ARTIFACtid> <version>2.6.1</version> </DE pendency> <!--spring MVC related.....end-- <!--m Ybatis Orm Related.....start- <dependency> &NBS P <groupId>org.springframework</groupId> <artifactId> spring-orm</artifactid> <version>${spring.version}</version > </dependency> <dependency> & nbsp <groupId>org.mybatis</groupId> <artifactId>
mybatis-spring</artifactid> <version>1.2.3</version> </DEPENDENCY> <dependency> <groupid>mysql</groupid > <artifactId>mysql-connector-java</artifactId> & nbsp <version>5.1.36</version> </dependency> <dependency> <groupId>org.mybatis</groupId> & nbsp <artifactId>mybatis</artifactId> <version>3.3.0</version> </dependency> <DEP endency> <groupId>c3p0</groupId> &NBS P <artifactId>c3p0</artifactId> <version>0.9.1.2</ Version>   </dependency> <dependency> <groupId>org.slf4j</groupId> <ARTIFACTID>SLF4J-LOG4J12 </artifactId> <version>1.7.12</version> </dependency> <!--mybatis Orm Related.....end-- & nbsp <!--project Log Related.....start-- <dependency> &N Bsp <groupId>log4j</groupId> <artifactid>log4j</ artifactid> <version>1.2.17</version> &NBSP ; </dependency> <!--project Log related.....end-- and lt;! --Redis Cache relAted.....start- <dependency> <groupid >org.springframework.data</groupId> <artifactId> spring-data-redis</artifactid> <version>1.6.0.release</ version> </dependency> <dependency> (+) nbsp <groupId>redis.clients</groupId> <
artifactid>jedis</artifactid> <version>2.7.3</version> </dependency> <!--Redis Cache Related.....end--&NB Sp <!--unit Test JUnit Jar--<dependency> <groupId>junit</groupId> <arti Factid>junit</artifactid> <version>4.12</version> </dependency> </dependencies> <build> & nbsp <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuratio n> <source>1.8</source> <target>1.8</target> &NBS P <encoding>utf8</encoding> </configuration> </plugin>
<plugin> <artifactId>maven-war-plugin</artifactId> & nbsp <version>2.4</version> &NB Sp <configuration> <warsourcedirectory& Gt webcontent</warsourcedirectory> <failonmis singwebxml>false</failonmissingwebxml> </ configuration> </plugin> </plugins> (+) nbsp </build> </project>
Project BASIC structure:
Jdbc.properties:
jdbc.host=127.0.0.1
jdbc.database=user
jdbc.port=3306
jdbc.username=root
jdbc.password=root
Log4j.properties:
# Global Logging Configuration
log4j.rootlogger=warn,stdout
# Console output ...
Log4j.appender.stdout=org.apache.log4j.consoleappender
log4j.appender.stdout.layout= Org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.conversionpattern=%d{yyyy-mm-dd HH:mm:ss}%-5p%c :%l-%m%n
# mybatis Log
log4j.logger.com.ssm.dao.usermapper=debug
# Lyz Log
Log4j.logger.com.ssm.controller=debug
Log4j.logger.com.ssm.service=debug
Redis.porperties:
# Redis Settings
redis.host=127.0.0.1
redis.port=6379
#redis. Pass=password
redis.dbindex=0
redis.expiration=3000
redis.maxidle=300
redis.maxactive=600
redis.maxwait=1000
Redis.testonborrow=true
Applicationcontext.xml:
<beans xmlns= "Http://www.springframework.org/schema/beans" xmlns:xsi= "http://www.w3.org/2001/ Xmlschema-instance "xmlns:context=" Http://www.springframework.org/schema/context "xmlns:aop="/HTTP/ Www.springframework.org/schema/aop "xmlns:tx=" http://www.springframework.org/schema/tx "xsi:schemalocation=" http
://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd Http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring- Context-4.0.xsd HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP http://www.springframework.org/schema/aop/spring-a Op-4.0.xsd Http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.x SD "> <!--class annotation related ... Start-and <context:component-scan base-package=" Com.ssm.serviceI Mpl "/> <context:component-scan base-package=" Com.ssm.utils " /> <!--class annotation related ... end--<!--MyBatis related ... Start-to-<bean class= "Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" > <property name= "Locations" > <list> <value>classpath:jdbc.properties</value> <val ue>classpath:redis.properties</value> </list> </property> </bean> &
Lt;bean id= "DataSource" class= "Com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method= "Close" >