<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>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [TOC] # 簡介 利用pipeline的方式從client打包多條命令一起發出,不需要等待單條命令的響應返回,而Redis服務端會處理完多條命令后會將多條命令的處理結果打包到一起返回給客戶端。所以pipeline適合批處理作業可以提升效率 # 管道 異步的方式,一次發送多個指令,并且,不同步等待其返回結果。這樣可以取得非常好的執行效率。 ~~~ Jedis jedis = this.init(); Set<String> keys = jedis.keys("k*"); List<Object> list = new ArrayList<>(); Pipeline pipelined = jedis.pipelined(); for (String key : keys) { pipelined.set(key, key + "---"); } pipelined.sync(); ~~~ 如果要返回參與打包執行的每條命令的結果 就可以這樣寫 ~~~ List<Object> list = pipelined.syncAndReturnAll(); System.out.println(list); ~~~ # 管道中調用事務 在某種需求下,我們需要異步執行命令,但是,又希望多個命令是有連續的,所以,我們就采用管道加事務的調用方式。jedis是支持在管道中調用事務的。 效率上可能會有所欠缺 ~~~ Jedis jedis = this.init(); Pipeline pipelined = jedis.pipelined(); pipelined.multi(); for (int i = 0; i < 5; i++) { pipelined.set("k-" + i, "v-" + i); } pipelined.exec(); //返回每個執行結果 List<Object> list = pipelined.syncAndReturnAll(); System.out.println(list); ~~~ 輸出 ~~~ [OK, QUEUED, QUEUED, QUEUED, QUEUED, QUEUED, [OK, OK, OK, OK, OK]] ~~~ # 注意 事務和管道都是異步模式。在事務和管道中不能同步查詢結果。比如下面兩個調用,都是不允許的: ## 管道中同步查詢 ~~~ Jedis jedis = this.init(); Pipeline pipelined = jedis.pipelined(); for (int i = 0; i < 5; i++) { System.out.println(pipelined.get("k-" + i)); } //返回每個執行結果 List<Object> list = pipelined.syncAndReturnAll(); System.out.println(list); ~~~ 返回 ~~~ Response string Response string Response string Response string Response string [v-0, v-1, v-2, v-3, v-4] ~~~ 如果要查詢就要在最后用syncAndReturnAll接收就行 ## 事務中同步查詢 ~~~ Jedis jedis = this.init(); Transaction multi = jedis.multi(); for (int i = 0; i < 5; i++) { System.out.println(multi.get("k-" + i)); } List<Object> exec = multi.exec(); System.out.println(exec); ~~~ 返回 ~~~ Response string Response string Response string Response string Response string [v-0, v-1, v-2, v-3, v-4] ~~~ 要知道結果就在最后獲取就行
                  <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>

                              哎呀哎呀视频在线观看