<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    常言笑的家

    Spring, Hibernate, Struts, Ajax, RoR

    Redis 3.X版本引入了集群的新特性的三種用法

    一、利用Jedis來(lái)實(shí)現(xiàn)

            Set<HostAndPort>  jedisClusterNodes = new HashSet<HostAndPort>();

              //Jedis Cluster will attempt to discover cluster nodes automatically

             jedisClusterNodes.add(new HostAndPort("10.96.5.183",9001));

             jedisClusterNodes.add(new HostAndPort("10.96.5.183",9002));

             jedisClusterNodes.add(new HostAndPort("10.96.5.183",9003));

            JedisCluster jc = new JedisCluster(jedisClusterNodes);

    二、利用spring-data-redis來(lái)實(shí)現(xiàn)

         <!--通過構(gòu)造方法注入RedisNode-->

         <bean id="clusterRedisNodes1"   class="org.springframework.data.redis.connection.RedisNode"> 

                <constructor-arg value="10.96.5.183" />

               <constructor-arg value="9002" type="int" />

         </bean>

         ....

        <!--setter方式注入-->

        <bean id="redisClusterConfiguration"   class="org.springframework.data.redis.connection.RedisClusterConfiguration">

           <property name="clusterNodes">

                  <set>

                            <ref bean="clusterRedisNodes1"/>

                           <ref bean="clusterRedisNodes2"/>

                           <ref bean="clusterRedisNodes3"/>

                  </set>

           </property>
        </bean>

      <!--setter方式注入,對(duì)應(yīng)的屬性需存在setterXXX方法-->


       <bean id="jedisPoolConfig"   class="redis.clients.jedis.JedisPoolConfig">

                <property name="maxToal" value="1000" />

               <property name="maxIdle" value="1000" />

               <property name="maxWaitMillis" value="1000" />

       </bean>

      <bean id="jedisConnFactory"   class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" p:use-pool="true">

               <constructor-arg ref="redisClusterConfiguration" />

               <constructor-arg ref="jedisPoolConfig" />

      </bean>

     <bean id="redisTemplate"   class="org.springframework.data.redis.core.RedisTemplate"  p:connection-factory-ref="jedisConnFactory" />

    <!--setter方式注入PersonRepoImpl-->

    <bean id="personRepo"  class="com.example.repo.impl.PersonRepoImpl">

           <property name="redisTemplate" ref="redisTemplate" />

    </bean>

    三、簡(jiǎn)單集成Spring

        自己編寫jedisCluster的工廠類JedisClusterFactory,然后通過Spring注入的方式獲取jedisCluster,實(shí)現(xiàn)客戶端使用Redis3.0版本的集群特性。

    posted on 2016-08-07 17:32 常言笑 閱讀(583) 評(píng)論(0)  編輯  收藏


    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     

    My Links

    Blog Stats

    常用鏈接

    留言簿(5)

    隨筆分類

    隨筆檔案

    搜索

    積分與排名

    最新評(píng)論

    閱讀排行榜

    評(píng)論排行榜

    主站蜘蛛池模板: jiz zz在亚洲| 精品一区二区三区免费观看| 激情综合亚洲色婷婷五月APP| 亚洲AV成人无码网天堂| 免费播放在线日本感人片| 西西大胆无码视频免费| 免费在线观看视频a| 亚洲国产精品网站久久| 黄色片网站在线免费观看| 日韩免费人妻AV无码专区蜜桃 | 国产成人高清精品免费鸭子| 亚洲AV无码国产丝袜在线观看| 亚洲AV无码专区在线电影成人| 日本特黄特黄刺激大片免费| 亚洲白色白色在线播放| fc2免费人成在线视频| 日韩精品视频免费观看| 美女被吸屁股免费网站| 亚洲一区精品无码| 亚洲国产精品无码观看久久| 国内精品免费麻豆网站91麻豆| 亚洲理论电影在线观看| j8又粗又长又硬又爽免费视频| 国产亚洲av片在线观看播放| 久久A级毛片免费观看| 亚洲人成网站在线观看播放| 99re6在线视频精品免费下载| 亚洲激情电影在线| 国产男女性潮高清免费网站| 国产精品玖玖美女张开腿让男人桶爽免费看 | 亚洲国产精品美女久久久久| 亚洲国产精品成人久久蜜臀| 亚洲天然素人无码专区| 久久精品成人免费网站| 亚洲国产日韩在线视频| 五月婷婷在线免费观看| 亚洲午夜成激人情在线影院| 最近中文字幕无免费| MM1313亚洲精品无码久久| 国产精品成人免费综合| 女人隐私秘视频黄www免费|