<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                JedisPoolUtil public class JedisPoolUtil { ? private static volatile JedisPool jedisPool = null;// 被volatile修飾的變量不會被本地線程緩存,對該變量的讀寫都是直接操作共享內存。 ? private JedisPoolUtil() { } ? public static JedisPool getJedisPoolInstance() { if (null == jedisPool) { synchronized (JedisPoolUtil.class) { if (null == jedisPool) { JedisPoolConfig poolConfig = new JedisPoolConfig(); poolConfig.setMaxTotal(1000); poolConfig.setMaxIdle(32); poolConfig.setMaxWaitMillis(100 \* 1000); poolConfig.setTestOnBorrow(true); ? jedisPool = new JedisPool(poolConfig, "192.168.120.129", 6379); } } } return jedisPool; } ? public static void release(JedisPool jedisPool, Jedis jedis) { if (null != jedis) { Jedis jedis2 = null; try { jedis2 = jedisPool.getResource(); } finally { jedis2.close(); } } } ? } 使用 public class TestJedisPool { public static void main(String\[\] args) { JedisPool jedisPool = JedisPoolUtil.getJedisPoolInstance(); Jedis jedis = null; ? try { jedis = jedisPool.getResource(); jedis.set("k18", "v183"); ? } catch (Exception e) { e.printStackTrace(); } finally { JedisPoolUtil.release(jedisPool, jedis); } } ? } ? 配置總結all JedisPool的配置參數大部分是由JedisPoolConfig的對應項來賦值的。 maxTotal/maxActive:控制一個pool可分配多少個jedis實例,通過pool.getResource()來獲取;如果賦值為-1,則表示不限制;如果pool已經分配了maxActive個jedis實例,則此時pool的狀態為exhausted。 maxIdle:控制一個pool最多有多少個狀態為idle(空閑)的jedis實例; whenExhaustedAction:表示當pool中的jedis實例都被allocated完時,pool要采取的操作;默認有三種。 WHEN\_EXHAUSTED\_FAIL --> 表示無jedis實例時,直接拋出NoSuchElementException; WHEN\_EXHAUSTED\_BLOCK --> 則表示阻塞住,或者達到maxWait時拋出JedisConnectionException; WHEN\_EXHAUSTED\_GROW --> 則表示新建一個jedis實例,也就說設置的maxActive無用; setMaxWaitMillis/maxWait:表示當borrow一個jedis實例時,最大的等待時間,如果超過等待時間,則直接拋JedisConnectionException; testOnBorrow:獲得一個jedis實例的時候是否檢查連接可用性(ping());如果為true,則得到的jedis實例均是可用的; testOnReturn:return 一個jedis實例給pool時,是否檢查連接可用性(ping()); testWhileIdle:如果為true,表示有一個idle object evitor線程對idle object進行掃描,如果validate失敗,此object會被從pool中drop掉;這一項只有在timeBetweenEvictionRunsMillis大于0時才有意義; timeBetweenEvictionRunsMillis:表示idle object evitor兩次掃描之間要sleep的毫秒數; numTestsPerEvictionRun:表示idle object evitor每次掃描的最多的對象數; minEvictableIdleTimeMillis:表示一個對象至少停留在idle狀態的最短時間,然后才能被idle object evitor掃描并驅逐;這一項只有在timeBetweenEvictionRunsMillis大于0時才有意義; softMinEvictableIdleTimeMillis:在minEvictableIdleTimeMillis基礎上,加入了至少minIdle個對象已經在pool里面了。如果為-1,evicted不會根據idle time驅逐任何對象。如果minEvictableIdleTimeMillis>0,則此項設置無意義,且只有在timeBetweenEvictionRunsMillis大于0時才有意義; lifo:borrowObject返回對象時,是采用DEFAULT\_LIFO(last in first out,即類似cache的最頻繁使用隊列),如果為False,則表示FIFO隊列; ================================================================================================================== 其中JedisPoolConfig對一些參數的默認設置如下: testWhileIdle=true minEvictableIdleTimeMills=60000 timeBetweenEvictionRunsMillis=30000 numTestsPerEvictionRun=-1 ?
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看