Redis+nginx +memcached 网络组件

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负载均衡 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值