<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)論排行榜

    主站蜘蛛池模板: 亚洲人成电影网站免费| 亚洲AV无码乱码在线观看裸奔| 亚洲中文字幕AV在天堂| 又大又硬又爽又粗又快的视频免费| 亚洲AV一宅男色影视| 色www永久免费| 亚洲成年人在线观看| 最近中文字幕完整免费视频ww| 亚洲成人免费电影| 我要看免费的毛片| 日本系列1页亚洲系列| 免费jlzzjlzz在线播放视频| 一级毛片免费播放试看60分钟| 亚洲午夜福利717| 99re6免费视频| 亚洲人成网站色在线观看| 日美韩电影免费看| 搜日本一区二区三区免费高清视频| 免费一级毛片清高播放| 中文字幕手机在线免费看电影| 亚洲第一精品在线视频| 日本阿v免费费视频完整版| 亚洲AV无码片一区二区三区| 亚洲麻豆精品国偷自产在线91| 免费国产午夜高清在线视频| 亚洲成年人免费网站| 免费鲁丝片一级在线观看| 一级毛片大全免费播放下载| 久久久久亚洲AV无码专区首JN| 国产一精品一AV一免费孕妇| 免费人成大片在线观看播放| 亚洲最大的成网4438| 无码人妻一区二区三区免费| 曰批全过程免费视频免费看 | 亚洲精品无码久久久久APP| 国产小视频在线免费| 国产免费无码AV片在线观看不卡| 亚洲av永久无码精品三区在线4| 免费在线视频一区| 亚洲毛片免费观看| 一个人看的www在线免费视频|