<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智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                #### 字符串命令 * * * * * ###### SET key value [EX seconds] [PX milliseconds] [NX|XX] 起始版本:1.0.0 時間復雜度:O(1) > Set key to hold the string value. If key already holds a value, it is overwritten, regardless of its type. Any previous time to live associated with the key is discarded on successful SET operation. 將鍵key設定為指定的“字符串”值。 如果 key 已經保存了一個值,那么這個操作會直接覆蓋原來的值,并且忽略原始類型。 當set命令執行成功之后,之前設置的過期時間都將失效 選項 從2.6.12版本開始,redis為SET命令增加了一系列選項: > EX seconds – Set the specified expire time, in seconds. > PX milliseconds – Set the specified expire time, in milliseconds. > NX – Only set the key if it does not already exist. > XX – Only set the key if it already exist. EX seconds – 設置鍵key的過期時間,單位時秒 PX milliseconds – 設置鍵key的過期時間,單位時毫秒 NX – 只有鍵key不存在的時候才會設置key的值 XX – 只有鍵key存在的時候才會設置key的值 注意: 由于SET命令加上選項已經可以完全取代SETNX, SETEX, PSETEX的功能,所以在將來的版本中,redis可能會不推薦使用并且最終拋棄這幾個命令。 返回值 simple-string-reply:如果SET命令正常執行那么回返回OK,否則如果加了NX 或者 XX選項,但是沒有設置條件。那么會返回nil。 例子 ~~~ redis> SET mykey "Hello" OK redis> GET mykey "Hello" ~~~ ###### GET key 起始版本:1.0.0 時間復雜度:O(1) 返回key的value。如果key不存在,返回特殊值nil。如果key的value不是string,就返回錯誤,因為GET只處理string類型的values。 返回值 simple-string-reply:key對應的value,或者nil(key不存在時) 例子 ~~~ redis> GET nonexisting (nil) redis> SET mykey "Hello" OK redis> GET mykey "Hello" ~~~ ###### MSET key value [key value ...] 起始版本:1.0.1 時間復雜度:O(N) where N is the number of keys to set. 對應給定的keys到他們相應的values上。MSET會用新的value替換已經存在的value,就像普通的SET命令一樣。如果你不想覆蓋已經存在的values,請參看命令MSETNX。 MSET是原子的,所以所有給定的keys是一次性set的。客戶端不可能看到這種一部分keys被更新而另外的沒有改變的情況。 返回值 simple-string-reply:總是OK,因為MSET不會失敗。 例子 ~~~ redis> MSET key1 "Hello" key2 "World" OK redis> GET key1 "Hello" redis> GET key2 "World" ~~~ ###### MGET key [key ...] 起始版本:1.0.0 時間復雜度:O(N) where N is the number of keys to retrieve. 返回所有指定的key的value。對于每個不對應string或者不存在的key,都返回特殊值nil。正因為此,這個操作從來不會失敗。 返回值 array-reply: 指定的key對應的values的list 例子 ~~~ redis> SET key1 "Hello" OK redis> SET key2 "World" OK redis> MGET key1 key2 nonexisting 1) "Hello" 2) "World" 3) (nil) redis> ~~~ * * * * * ###### APPEND key value 起始版本:2.0.0 時間復雜度:O(1)。均攤時間復雜度是O(1), 因為redis用的動態字符串的庫在每次分配空間的時候會增加一倍的可用空閑空間,所以在添加的value較小而且已經存在的 value是任意大小的情況下,均攤時間復雜度是O(1) 。 如果 key 已經存在,并且值為字符串,那么這個命令會把 value 追加到原來值(value)的結尾。 如果 key 不存在,那么它將首先創建一個空字符串的key,再執行追加操作,這種情況 APPEND 將類似于 SET 操作。 返回值 Integer reply:返回append后字符串值(value)的長度。 ##例子 ~~~ redis> EXISTS mykey (integer) 0 redis> APPEND mykey "Hello" (integer) 5 redis> APPEND mykey " World" (integer) 11 redis> GET mykey "Hello World" ~~~ * * * * * ###### GETRANGE key start end 起始版本:2.4.0 時間復雜度:O(N) N是字符串長度,復雜度由最終返回長度決定,但由于通過一個字符串創建子字符串是很容易的,它可以被認為是O(1)。 警告:這個命令是被改成GETRANGE的,在小于2.0的Redis版本中叫SUBSTR。 返回key對應的字符串value的子串,這個子串是由start和end位移決定的(兩者都在string內)。可以用負的位移來表示從string尾部開始數的下標。所以-1就是最后一個字符,-2就是倒數第二個,以此類推。 這個函數處理超出范圍的請求時,都把結果限制在string內。 返回值 bulk-reply 例子 ~~~ redis> SET mykey "This is a string" OK redis> GETRANGE mykey 0 3 "This" redis> GETRANGE mykey -3 -1 "ing" redis> GETRANGE mykey 0 -1 "This is a string" redis> GETRANGE mykey 10 100 "string" ~~~
                  <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>

                              哎呀哎呀视频在线观看