1、redis是一个nosql的数据库,操作内存数据,并可以将其存储到硬盘中来持久化
2、与spring的整合 http://www.cnblogs.com/holdouts/articles/5811118.html
需要jar包common-pool2.jar jedis.jar spring-data-redis.jar
spring 配置文件
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
default-autowire="byName">
<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxIdle" value="${redis.maxIdle}"></property>
<property name="minEvictableIdleTimeMillis" value="${redis.minEvictableIdleTimeMillis}"></property>
<property name="numTestsPerEvictionRun" value="${redis.numTestsPerEvictionRun}"></property>
<property name="timeBetweenEvictionRunsMillis" value="${redis.timeBetweenEvictionRunsMillis}"></property>
</bean>
<bean id="jedisConnectionFactory"
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
destroy-method="destroy">
<property name="poolConfig" ref="jedisPoolConfig"></property>
<property name="hostName" value="${redis.hostName}"></property>
<property name="port" value="${redis.port}"></property>
<property name="timeout" value="${redis.timeout}"></property>
<property name="usePool" value="${redis.usePool}"></property>
</bean>
<bean id="jedisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="jedisConnectionFactory"></property>
<property name="keySerializer">
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer" /> //代表redis的key/value需要序列化 若是实体类,实体类需要实现序列化
</property>
<property name="valueSerializer">
<bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" />
</property>
</bean>
</beans>
@Autowired
@Qualifier("jedisTemplate")
public RedisTemplate redisTemplate;
需要redis的类中,可以注入redisTemplate
有5种数据操作方式
redisTemplate.opsForValue();//操作字符串
redisTemplate.opsForHash();//操作hash
redisTemplate.opsForList();//操作list
redisTemplate.opsForSet();//操作set
redisTemplate.opsForZSet();//操作
3、nginx的安装与部署
http://blog.csdn.net/kingzma/article/details/46331999
http://www.runoob.com/linux/nginx-install-setup.html
cd /home/soft
yum install openssl yum install openssl-devel
yum install zlib-devel yum install zlib
yum install pcre-devel yum install pcre
下载nginx
wget http://nginx.org/download/nginx-1.13.3.tar.gz
解压 tar -zxvf nginx-1.13.3.tar.gz
重命名 mv nginx-1.33.3 nginx
安装 c yum install -y gcc gcc-c++
编译nginx cd /home/soft/nginx
./configure
安装 make make install
默认安装目录 /usr/local/nginx
关闭默认防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
nginx负载均衡