Php-redis three of Chinese documents

Source: Internet
Author: User
This article is the third part of the Php-redis Chinese document, followed by an article, continue to introduce the use of some of the official Redis command skills, the need for friends can refer to.

This article is the third part of the Php-redis Chinese document, followed by an article, continue to introduce the use of some of the official Redis command skills, the need for friends can refer to.

Linsert in a list named key, find value for pivot and Redis::before by parameter | Redis::after, to make sure that the newvalue is placed in front of the pivot, or behind. If key does not exist, it will not be inserted if Pivot does not exist, Return-1$redis->delete (' Key1 '); $redis->linsert (' Key1 ', Redis::after, ' A ', ' X '); $redis->lpush (' Key1 ', ' A '); $redis->lpush (' Key1 ', ' B '); $redis->lpush (' Key1 ', ' C '); $redis->linsert (' Key1 ', Redis::before, ' C ', ' X '), $redis->lrange (' Key1 ', 0,-1); $redis->linsert (' Key1 ', Redis::after, ' C ', ' Y '); $redis->lrange (' Key1 ', 0,-1); $redis->linsert (' Key1 ', Redis::after, ' W ', ' value '); Rpoplpush returns and removes the tail element of the list named Srckey and adds the element to the head of the list named Dstkey $redis->delete (' x ', ' y '); $redis->lpush (' x ', ' ABC '); $redis->lpush (' x ', ' Def '); $redis->lpush (' y ', ' 123 '); $redis->lpush (' y ', ' 456 '); Move the last of the front of Y. Var_dump ($redis->rpoplpush (' x ', ' y ')) Var_dump ($redis->lrange (' x ', 0,-1)); Var_dump ($redis->lrange (' Y ', 0,-1)); String (3) "abc" Array (1) {[0]=> string (3) "Def"} Array (3) {[0]=> string (3) "ABC" [1]=> String (3) "456" [2]=> string (3) "123"} Set operation related Sadd add element value to set named Key, if value exists, does not write, return false$redis-> Sadd (key, value); Srem, sremove Delete the element value$redis->sadd (' Key1 ', ' Set1 ') in the set named Key, $redis->sadd (' Key1 ', ' Set2 '); $redis->sadd (' Key1 ', ' set3 '); $redis->srem (' Key1 ', ' Set2 '); Smove moves the value element from a collection named Srckey to a collection named Dstkey $redis->smove (Seckey, Dstkey, value); Sismember, the scontains name is called the set of key to find if there is a value element, there is ture no False$redis->sismember (key, value); SCard, Ssize returns the number of elements of a set named key Spop randomly returns and deletes an element in a set named key Srandmember randomly returns an element in a set named key, without deleting sinter for intersection Sinterstore the intersection and saves the intersection to the set of output $redis->sinterstore (' Output ', ' key1 ', ' key2 ', ' Key3 ') Sunion Seek and set $redis->sunion ( ' S0 ', ' s1 ', ' S2 '); s0,s1,s2 simultaneously asks for and sets Sunionstore and saves the set to the Output collection $redis->sunionstore (' Output ', ' key1 ', ' key2 ', ' Key3 '); Sdiff the difference set Sdiffstore the difference set and saves the difference set to the set of output smembers, Sgetmembers returns all elements of a set named key sort, paging, and other parameters ' by ' = ' some_ Pattern_* ', ' limit ' = = = Array (0, 1), ' get ' = ' some_other_pattern_* ' or an arrAy of patterns, ' sort ' = ' asc ' or ' desc ', ' alpha ' = ' = ', ' store ' = ' External-key ' example $redis->delete (' s '); $redis->sadd (' s ', 5); $redis->sadd (' s ', 4); $redis->sadd (' s ', 2); $redis->sadd (' s ', 1); $redis->sadd (' s ', 3); Var_dump ($redis->sort (' s ')); 1,2,3,4,5var_dump ($redis->sort (' s ', array (' sort ' = ' desc '))); 5,4,3,2,1var_dump ($redis->sort (' s ', array (' sort ' = ' desc ', ' store ' = ' out '))); (int) 5 string command Getset returns the value from the original key and writes value to Key$redis->set (' x ', ' a '); $exValue = $redis->getset (' x ', ' lol '); Return ' replaces x by ' lol ' $newValue = $redis->get (' x ') '//return ' LOL ' appendstring, string with the name key appended with value $redis->set (' key ', ' value1 '); $redis->append (' key ', ' value2 '); $redis->get (' key ');

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.