Redis作为现在最流行的缓存技术,把接收到的数据,转换为硬盘数据或者数据库,存储在缓存中,减少多重数据同时的压力,
也可以实现单点,主要作为缓存
1.先分享一些配置pom.xml
<dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId> </dependency> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.9.0</version> </dependency>
2.再看一下redis的配置
#### Redis
com.oneinlet.config.redisConfig.maxTotal=
30
com.oneinlet.config.redisConfig.maxIdle=
10
com.oneinlet.config.redisConfig.maxWaitMillis=
51000
com.oneinlet.config.redisConfig.minIdle=
5
com.oneinlet.config.redisConfig.port=
6379
com.oneinlet.config.redisConfig.hostName=
localhost
com.oneinlet.config.redisConfig.password=
123456
com.oneinlet.config.redisConfig.timeout=
15000
3.controller的方法
@RequestMapping(
"/putValueToRedis/{name}")
public Object getRedis(
@PathVariable String name) {
redisService.setKeyValue(name,
"www.520code.net");
return setOKResult(); }