Command sharing for the PHP operation Redis

Source: Internet
Author: User
Tags first string redis server

This article is mainly to share with you PHP operation Redis Life, hope to help everyone.

To confirm that the server has the Redis service turned on
The Redis port number is 6379 by default

A small example code

Header ("Content-type:text/html;charset=utf8"); Declares the Redis object instance redis->connect ("localhost", 6379); If Redis turns on security authentication, then we need to use the Auth method in Redis to pass the secure authentication password $redis->auth ("123456");//Redis->hmset ("Stars:jay", Array (" Name "= ' Jay Chou ', ' age ' =>33, ' lover ' = ' blue Ball '); Gets the value of the hash Table//Redis->hgetall ("Stars:jay");//Use the Sadd method to add an unordered collection called Lessons//Redis->sadd ("Lessons", "Java"); Use the Smembers method to get all the elements in an unordered collection//Redis->smembers ("lessons"); Use the Zadd method to add an ordered set called Girls//Redis->zadd ("Girls", 4, "the"); data=data1= $redis->zrevrange ("Girls", 0,-1);  Descending gets the collection's data//message queue//exists to determine if this key name exists if (Movies = Array (     "17:00 is playing movie < leaf Q 3>",     "20:00 starts playing movie < leaf Q 4 > ",     " 22:00 is playing the movie < leaf Q 5> ", and the     foreach (movie) {     //rpush is pressed into the list movie as a queue);}
Connect the local Redis service $redis = new Redis (), $redis->connect (' 127.0.0.1 ', 6379); $redis->auth (' 123456 ');/************** **key (key) ****************///del key [key ...] --Delete the given one or more Keyredis->del (array (' XRJ ', ' ly ', ' FJF ')),//keys pattern--Find all Keyredis->keys (' * ') that match the pattern of the given patterns //randomkey--is returned randomly from the current database (not deleted) a keyredis->randomkey ();//ttl key--returns the remaining lifetime (TTL, Time to live) of a given key in seconds//pttl key--returns the remaining lifetime of the given key Redis->ttl (' BBS ') in milliseconds,//exists key--checks if the given key exists, exists, returns 1, or returns 0redis->exists (' email ') //move key db--moves the key of the current database to the given DB Redis->move (' email ', 1), $redis->select (1); Redis->keys (' * '); redis- >move (' email ', 0);//rename key newkey--renamed key to Newkeyredis->rename (' email ', ' e-eamil.com '); Redis->rename (' E-eamil.com ', ' eamil ');//renamenx key newkey--when and only if Newkey does not exist, rename key to Newkeyredis->renamenx (' BBS ', ' bbs1 ');//type key--returns the type of value stored by key redis->type (' PageView '),//expire key seconds--sets the time to live for key, and when key expires, it is automatically deleted//pexpire key milliseconds--the lifetime of the key in milliseconds//expireat the key timestamp--command accepts the time parameterNumber is a Unix timestamp, key survives to a UNIX timestamp time//persist key--removes the lifetime of a given key, converts to a Key//sort key with no lifetime, never expires [by pattern] [LIMIT offset Count] [get pattern [get pattern ...]] [ASC | DESC] [ALPHA] [STORE destination]--Returns or saves a sorted element/***********string (string) related action **********///set key in a given list, collection, ordered collection key value--the string value value to key, which overwrites Redis->set (' email ', ' jiang@58haha.cn '),//setnx key value--sets the value of key to value, When and only if key does not exist, successful return 1, unsuccessful return 0redis->setnx (' email ', ' jiang@58haha.cn ');//setex key seconds value--Associates value And the lifetime of the key is set to seconds (in seconds) Redis->setex (' name ', 10086, ' Jiang '),//psetex key milliseconds value--command is similar to Setex command, It sets the lifetime of key in milliseconds Redis->psetex (' Jiang ', 90000, ' hahaha ');//mset key value [key value ...] --simultaneously set one or more Key-value to Redis->mset (Array (' ly ' = ' liyang ', ' fjf ' = ' Fengjingfeng '));//msetnx key value [key Value ...] --Set one or more key-value pairs at the same time, when and only if the given key does not exist Redis->msetnx (array (' ly ' = ' = ' Liyang ', ' xrj ' = ' Xingrongjiang ', ' fjf ' = > ' Fengjingfeng ')//append key value--If the key already exists and is a string, the APPEND command appends value to the end of the original value of the key. If KeY does not exist, append is like executing set key value redis->append (' ly ', ' love '),//get key--returns the string value associated with key, if key does not exist then return a special value nil, Get can only be used to process string values Redis->get (' ly ');//mget key [key ...] --Returns the value of all (one or more) given key, if there is a key in the given key does not exist, then this key returns the special value nil, the command will never fail redis->mget (' email ', ' ly ', ' fjf ');// GETRANGE Key start end--returns a substring of the string value in key, the Intercept range of the string is determined by the start and end two offsets (including start and end), the negative offset represents the last count from the string, 1 represents the last character,- 2 means the penultimate redis->getrange (' email ', 0,-1); From the first to the last, the equivalent of the direct Get//getset key value--sets the value of the given key to value and returns the old value of key redis->getset (' email ', ' Jiangzunshao@163.com ');//strlen key--Returns the length of the string value stored by key Redis->strlen (' email ');//decr key--minus one of the numeric values stored in key If the key does not exist, then the value of key is initialized to 0 first, then the DECR operation REDIS-&GT;DECR (' PageView '),//INCR key--the value stored in the key to increase the number of one, if key does not exist, Then the value of key is initialized to 0, then the incr operation REDIS-&GT;INCR (' Pageview1 '),//decrby key decrement--the value stored by the key minus the decrement decrement (can be negative) Redis->decrby (' PageView ', 3);//incrby key increment--adds the value stored by the key to the increment increment (can be negative) Redis->incrby (' PageView ', 6);/***********hash (hash table) Related Operations **********///hset key field Value--sets the value of the field field in the hash table key to value, new returns 1, Overrides return 0redis->hset ("User", "jiang@58haha.cn", "{' Name ': ' Jiangzunshao ', ' age ' : "Work": ' php ', ' City ': ' Beijing '} ");//hsetnx key field value--sets the value of the field field in the hash table key to value when and only if the domain field does not exist. Set success, return 1. If it already exists and no action is performed, return 0redis->hsetnx ("User", "jiang@58haha.cn", "{' Name ': ' Jiangzunshao ', ' Age ': '", ' working ': ' php ', ' City ': ' Beijing '} ");//hget key field--Returns the value of the given field field in the hash table key Redis->hget (" user "," jiang@58haha.cn ");//hmset key field value [Field value ...] --Simultaneously set multiple Field-value (domain-value) pairs to the hash table key Redis->hmset (' user ', Array (' name ' = ' Jiangzunshao ', ' age ' = 20));// Hmget key field [field ...] --Returns the value of one or more given fields in the hash table key Redis->hmget (' user ', Array (' name ', ' age '));//hgetall key--returns the hash table key, all fields and values redis-> Hgetall (' user ');//hdel key field [field ...] --delete one or more specified domains in the hash table key, the nonexistent domain will be ignored Redis->hdel (' user ', ' age '),//hlen key--returns the number of fields in the hash table key Redis->hlen (' user ');/ Hexists key field--View Hash table key, whether a given domain field exists, exists return 1, does not exist return 0redis->hexists (' user ', ' jiang@58haha.cn ');//hincrby key Field increment--is in hash table keyThe value of the Field field plus the increment increment can be negative redis->hincrby (' user ', ' PV ', 5);//hkeys key--returns all domains in the hash table key Redis->hkeys (' user '); /hvals key--Returns the value of all fields in the hash table key redis->hvals (' user ');/***********list (list) related Operations **********///lpush key value [value ...] --insert data into the head of the list $redis->lpush (' dbs ', ' mongodb-3.2 ');//rpush key value [value ...] --insert data into the tail of the list $redis->rpush (' dbs ', ' Redis ');//llen key--Get the length of the list Redis->llen (' dbs ');//lpop key-- Remove and return the header element of the list Redis->lpop (' dbs ');//rpop key--Remove and return the tail element of the list Redis->rpop (' dbs ');//lrange key Start stop-- Returns the specified interval within the list of elements Redis->lrange (' dbs ', 0, $redis->llen (' dbs ')); Redis->lrange (' dbs ', 0,-1);//lset Key index value- -Set the value of the element labeled Index to Valueredis->lset (' DBS ', 1, ' Jiang ');//ltrim key start stop--list retains only elements within the specified interval Redis->ltrim (' DBS ', 3,5);//lindex key index--Returns the element labeled index in the list redis->lindex (' dbs ', $redis->llen (' DBS ')-1);//linsert key before| After pivot value--inserts values into the list, either before or after the value pivot Redis->linsert (' dbs ', Redis::before, ' MySQL ', ' mysqlmysql '); Redis->linsert (' dbs ', Redis::after, ' Redis ', ' redisreDis ');//rpoplpush source destination--command Rpoplpush performs the following two actions in an atomic time: 1, pops the last element in the list source (the trailing element) and returns it to the client; 2, Inserts the source popup element into the list destination, as the head element of the destination list Redis->rpoplpush (' Dbs1 ', ' dbs ');/***********set (collection) Related Operations * * * * Sadd key member [member ...] --adding one or more member elements to the collection key, the member element that already exists in the collection will be ignored Redis->sadd (' Set ', ' Xingrongjiang ');//srem key member [member ...] --Removes one or more member elements from the collection key, the nonexistent member element is ignored Redis->srem (' Set ', ' Array '),//smembers key--returns all the members in the collection key redis-> Smembers (' Set ');//sismember key member--determines whether the member element is a member of the collection Key Redis->sismember (' Set ', ' Liyang ');//scard key-- Returns the cardinality of the collection key (the number of elements in the collection) Redis->scard (' Set ');//smove source Destination member-- Move the member element from the source collection to the destination collection Redis->smove (' Set ', ' Set1 ', ' Xingrongjiang ');//spop key-- Removes and returns a random element in the collection Redis->spop (' Set ');//srandmember key [count]--returns a random element in the collection if only the key argument is provided, if count is positive and less than the collection cardinality, Returns an array containing count elements, with different elements in the array, and if count is greater than or equal to the collection cardinality, returns the entire collection, and if count is a negative number, the command returns an array in which the elements in the array may recur multiple times. The length of the array is the absolute value of Count Redis->srandmember (' Set ', 2);//SINTER key [Key ...] --Returns all members of a collection, which is the intersection of all given sets Redis->sinter (' Set ');//sinterstore destination key [key ...] --Similar to the Sinter command, which saves the result to the destination collection instead of simply returning the result set Redis->sinterstore (' Haha ', ' set ');//sunion key [key ...] --Returns all members of a collection that are the Redis->sunion (' Set ', ' Set1 ') for all given collections;//sunionstore destination key [key ...] --Similar to the Sunion command, which saves the result to the destination collection instead of simply returning the result set Redis->sunionstore (' haha1 ', ' haha ', ' set1 ');//sdiff key [key ...] --Returns all members of a collection, which is the difference between all given sets Redis->sdiff (' Set ', ' Set1 '),/****** ordered set (Sorted set) related Operations *****///zadd key score member ---Add the element Member,score to the zset named key for sorting, and if the element already exists, update the order of the element according to score Redis->zadd (' site ', ' google.com '); redis- >zadd (' site ', 9, ' baidu.com '); Redis->zadd (' site ', 8, ' sina.com.cn ');//zrem key member--Delete the element in Zset named key member Redis->zrem (' site ', ' sina.com.cn ');//zcard key--returns the number of all elements of Zset with the name Key Redis->zcard (' site ');//zcount Key min max--returns the number of members in the ordered set key, score values between Min and Max Redis->zcount (' site ', 6,9);//zscore key member--returns an ordered set of key, Score value of member member Redis->zscore (' SitE ', ' baidu.com ');//zincrby key Increment member--is the member value of the member score of the ordered set key plus the increment increment, The return value is the result of score plus increment Redis->zincrby (' site ', ' ten ', ' baidu.com ');//zrange key start Stop [withscores]--returns an ordered set of key, A member within the specified interval, where the member's position is incremented by the score value (from small to large) to sort redis->zrange (' site ', 0,-1); Redis->zrange (' site ', 0,-1,true);//zrevrange Key start Stop [withscores]--returns the member in the ordered set key, within the specified interval, where the member's position is reduced by the score value (from large to small) to arrange the Redis->zrevrange (' site ', 0,-1); redis- >zrevrange (' site ', 0,-1,true);/***********connection (connection) **********///auth password--password Authentication redis->auth (' 123456 ');//ping--View connection Status redis->ping ();//select index--switch to the specified database, index number is specified with a numeric value, 0 is the starting index value, and NO. 0 database is used by default redis- >select (1);/***********server (server) **********///time--returns the current server time, a list of two strings: the first string is the current time in UNIX timestamp format. The second string is the number of microseconds that have elapsed in the current second redis->time ();//dbsize-– returns the number of keys for the current database Redis->dbsize ();//bgrewriteaof-- Use AOF for database Persistence redis->bgrewriteaof ();//save--save data synchronously to disk Redis->save ();//bgsave--asynchronously saves data to disk Redis->bgsave ();//lastsave--returns the Unix timestamp of the last successful save of data to disk redis->lastsAve ();//slaveof host port--Select from server $redis->slaveof (' 10.0.1.7 ', 6379),//flushall--empty data for entire Redis server (delete all keys for all databases) $ Redis->flushall ();//flushdb--clears all key$redis->flushdb () from the current database;//info [section]--returns about Redis Various information and statistical values of the server Redis->info (); Verify that the server has a Redis service port number default is 63,791 small example code header ("content-type:text/html;charset= UTF8 "); Declares the Redis object instance redis->connect ("localhost", 6379); If Redis turns on security authentication, then we need to use the Auth method in Redis to pass the secure authentication password $redis->auth ("123456");//Redis->hmset ("Stars:jay", Array (" Name "= ' Jay Chou ', ' age ' =>33, ' lover ' = ' blue Ball '); Gets the value of the hash Table//Redis->hgetall ("Stars:jay");//Use the Sadd method to add an unordered collection called Lessons//Redis->sadd ("Lessons", "Java"); Use the Smembers method to get all the elements in an unordered collection//Redis->smembers ("lessons"); Use the Zadd method to add an ordered set called Girls//Redis->zadd ("Girls", 4, "the");  data=data1= $redis->zrevrange ("Girls", 0,-1);     Descending gets the collection's data//message queue//exists to determine if this key name exists if (Movies = Array ("17:00 is playing movie < leaf Q 3>", "20:00 is playing movie < leaf Q 4>", "22:00 is playing movie < leaf Q 5>",); foreach (MoVIE) {//rpush is pressed into the list movie as a queue);} Connect the local Redis service $redis = new Redis (), $redis->connect (' 127.0.0.1 ', 6379); $redis->auth (' 123456 ');/************** **key (key) ****************///del key [key ...] --Delete the given one or more Keyredis->del (array (' XRJ ', ' ly ', ' FJF ')),//keys pattern--Find all Keyredis->keys (' * ') that match the pattern of the given patterns //randomkey--is returned randomly from the current database (not deleted) a keyredis->randomkey ();//ttl key--returns the remaining lifetime (TTL, Time to live) of a given key in seconds//pttl key--returns the remaining lifetime of the given key Redis->ttl (' BBS ') in milliseconds,//exists key--checks if the given key exists, exists, returns 1, or returns 0redis->exists (' email ') //move key db--moves the key of the current database to the given DB Redis->move (' email ', 1), $redis->select (1); Redis->keys (' * '); redis- >move (' email ', 0);//rename key newkey--renamed key to Newkeyredis->rename (' email ', ' e-eamil.com '); Redis->rename (' E-eamil.com ', ' eamil ');//renamenx key newkey--when and only if Newkey does not exist, rename key to Newkeyredis->renamenx (' BBS ', ' bbs1 ');//type key--returns the type of value stored by key redis->type (' PageView '),//expire key seconds--sets the time to live for key, and when key expires, it is automatically deleted//pexpire key milliseconds--setting key in millisecondsThe time to live//expireat key timestamp--command is a UNIX timestamp, key survives to a UNIX timestamp time//persist key--removes the lifetime of a given key, converts it to a time without a lifetime, Never Expires Key//sort key [by pattern] [LIMIT offset count] [get pattern [get pattern ...]] [ASC | DESC] [ALPHA] [STORE destination]--Returns or saves a sorted element/***********string (string) related action **********///set key in a given list, collection, ordered collection key value--the string value value to key, which overwrites Redis->set (' email ', ' jiang@58haha.cn '),//setnx key value--sets the value of key to value, When and only if key does not exist, successful return 1, unsuccessful return 0redis->setnx (' email ', ' jiang@58haha.cn ');//setex key seconds value--Associates value And the lifetime of the key is set to seconds (in seconds) Redis->setex (' name ', 10086, ' Jiang '),//psetex key milliseconds value--command is similar to Setex command, It sets the lifetime of key in milliseconds Redis->psetex (' Jiang ', 90000, ' hahaha ');//mset key value [key value ...] --simultaneously set one or more Key-value to Redis->mset (Array (' ly ' = ' liyang ', ' fjf ' = ' Fengjingfeng '));//msetnx key value [key Value ...] --Set one or more key-value pairs at the same time, when and only if the given key does not exist Redis->msetnx (array (' ly ' = ' = ' Liyang ', ' xrj ' = ' Xingrongjiang ', ' fjf ' = > ' Fengjingfeng ')//append key value--if key already exists andis a string, the append command appends value to the end of the original value of the key. If key does not exist, append is like executing set key value redis->append (' ly ', ' love '),//get key--returns the string value associated with key, and returns the special value nil if key does not exist. Get can only be used to process string values Redis->get (' ly ');//mget key [key ...] --Returns the value of all (one or more) given key, if there is a key in the given key does not exist, then this key returns the special value nil, the command will never fail redis->mget (' email ', ' ly ', ' fjf ');// GETRANGE Key start end--returns a substring of the string value in key, the Intercept range of the string is determined by the start and end two offsets (including start and end), the negative offset represents the last count from the string, 1 represents the last character,- 2 means the penultimate redis->getrange (' email ', 0,-1); From the first to the last, the equivalent of the direct Get//getset key value--sets the value of the given key to value and returns the old value of key redis->getset (' email ', ' Jiangzunshao@163.com ');//strlen key--Returns the length of the string value stored by key Redis->strlen (' email ');//decr key--minus one of the numeric values stored in key If the key does not exist, then the value of key is initialized to 0 first, then the DECR operation REDIS-&GT;DECR (' PageView '),//INCR key--the value stored in the key to increase the number of one, if key does not exist, Then the value of key is initialized to 0, then the incr operation REDIS-&GT;INCR (' Pageview1 '),//decrby key decrement--the value stored by the key minus the decrement decrement (can be negative) Redis->decrby (' PageView ', 3);//incrby key increment--adds the value stored by the key to the increment increment (can be negative) Redis->incrby (' PageView ', 6);/***********hash (haOperation **********///hset Key field value--sets the value of the field field in the hash table key to value, new returns 1, Overrides return 0redis->hset ("User", " Jiang@58haha.cn "," {' Name ': ' Jiangzunshao ', ' age ': +, ' work ': ' php ', ' City ': ' Beijing '} ');//hsetnx key field value-- Set the value of the field field in the hash table key to value if and only if the domain field does not exist. Set success, return 1. If it already exists and no action is performed, return 0redis->hsetnx ("User", "jiang@58haha.cn", "{' Name ': ' Jiangzunshao ', ' Age ': '", ' working ': ' php ', ' City ': ' Beijing '} ");//hget key field--Returns the value of the given field field in the hash table key Redis->hget (" user "," jiang@58haha.cn ");//hmset key field value [Field value ...] --Simultaneously set multiple Field-value (domain-value) pairs to the hash table key Redis->hmset (' user ', Array (' name ' = ' Jiangzunshao ', ' age ' = 20));// Hmget key field [field ...] --Returns the value of one or more given fields in the hash table key Redis->hmget (' user ', Array (' name ', ' age '));//hgetall key--returns the hash table key, all fields and values redis-> Hgetall (' user ');//hdel key field [field ...] --delete one or more specified domains in the hash table key, the nonexistent domain will be ignored Redis->hdel (' user ', ' age '),//hlen key--returns the number of fields in the hash table key Redis->hlen (' user ');/ Hexists key field--View Hash table key, whether the given domain field exists, exists return 1, there is no return 0redis->hexists (' user ', ' jiang@58haha.cn ');Hincrby key field increment--is the value of the field field in the hash table key plus the increment increment, which can be negative redis->hincrby (' user ', ' PV ', 5);//hkeys key-- Returns all domain Redis->hkeys (' user ') in the hash table key,//hvals key--returns the value of all fields in the hash table key redis->hvals (' user ');/***********list (list) Related actions **********///lpush key value [value ...] --insert data into the head of the list $redis->lpush (' dbs ', ' mongodb-3.2 ');//rpush key value [value ...] --insert data into the tail of the list $redis->rpush (' dbs ', ' Redis ');//llen key--Get the length of the list Redis->llen (' dbs ');//lpop key-- Remove and return the header element of the list Redis->lpop (' dbs ');//rpop key--Remove and return the tail element of the list Redis->rpop (' dbs ');//lrange key Start stop-- Returns the specified interval within the list of elements Redis->lrange (' dbs ', 0, $redis->llen (' dbs ')); Redis->lrange (' dbs ', 0,-1);//lset Key index value- -Set the value of the element labeled Index to Valueredis->lset (' DBS ', 1, ' Jiang ');//ltrim key start stop--list retains only elements within the specified interval Redis->ltrim (' DBS ', 3,5);//lindex key index--Returns the element labeled index in the list redis->lindex (' dbs ', $redis->llen (' DBS ')-1);//linsert key before| After pivot value--inserts values into the list, either before or after the value pivot Redis->linsert (' dbs ', Redis::before, ' MySQL ', ' mysqlmysql '); Redis->linsERT (' DBS ', Redis::after, ' Redis ', ' Redisredis ');//rpoplpush source destination--command Rpoplpush perform the following two actions within an atomic time: 1, POPs the last element in the list source (the trailing element) and returns it to the client; 2, inserts the source popup element into the list destination, as the head element of the destination list Redis->rpoplpush (' DBS1 ' , ' DBS ');/***********set (collection) related Operations **********///sadd key member [member ...] --adding one or more member elements to the collection key, the member element that already exists in the collection will be ignored Redis->sadd (' Set ', ' Xingrongjiang ');//srem key member [member ...] --Removes one or more member elements from the collection key, the nonexistent member element is ignored Redis->srem (' Set ', ' Array '),//smembers key--returns all the members in the collection key redis-> Smembers (' Set ');//sismember key member--determines whether the member element is a member of the collection Key Redis->sismember (' Set ', ' Liyang ');//scard key-- Returns the cardinality of the collection key (the number of elements in the collection) Redis->scard (' Set ');//smove source Destination member-- Move the member element from the source collection to the destination collection Redis->smove (' Set ', ' Set1 ', ' Xingrongjiang ');//spop key-- Removes and returns a random element in the collection Redis->spop (' Set ');//srandmember key [count]--returns a random element in the collection if only the key argument is provided, if count is positive and less than the collection cardinality, Returns an array containing count elements, with different elements in the array, and returns the entire collection if count is greater than or equal to the collection cardinality, and if count is a negative number, the command returns an array in which the elements in the array may be repeated multiple times, and the length of the array is couThe absolute value of NT Redis->srandmember (' Set ', 2);//sinter key [key ...] --Returns all members of a collection, which is the intersection of all given sets Redis->sinter (' Set ');//sinterstore destination key [key ...] --Similar to the Sinter command, which saves the result to the destination collection instead of simply returning the result set Redis->sinterstore (' Haha ', ' set ');//sunion key [key ...] --Returns all members of a collection that are the Redis->sunion (' Set ', ' Set1 ') for all given collections;//sunionstore destination key [key ...] --Similar to the Sunion command, which saves the result to the destination collection instead of simply returning the result set Redis->sunionstore (' haha1 ', ' haha ', ' set1 ');//sdiff key [key ...] --Returns all members of a collection, which is the difference between all given sets Redis->sdiff (' Set ', ' Set1 '),/****** ordered set (Sorted set) related Operations *****///zadd key score member ---Add the element Member,score to the zset named key for sorting, and if the element already exists, update the order of the element according to score Redis->zadd (' site ', ' google.com '); redis- >zadd (' site ', 9, ' baidu.com '); Redis->zadd (' site ', 8, ' sina.com.cn ');//zrem key member--Delete the element in Zset named key member Redis->zrem (' site ', ' sina.com.cn ');//zcard key--returns the number of all elements of Zset with the name Key Redis->zcard (' site ');//zcount Key min max--returns the number of members in the ordered set key, score values between Min and Max Redis->zcount (' site ', 6,9);//zscore Key member--return ordered set KeY, the member member the score Value Redis->zscore (' site ', ' baidu.com ');//zincrby key Increment member-- For the score value of the member member of the ordered set key plus the increment increment, the return value is score plus increment result Redis->zincrby (' site ', ' baidu.com ');//zrange Key start Stop [withscores]--returns the member in the ordered set key, within the specified interval, where the member's position is incremented by the score value (from small to large) to sort redis->zrange (' site ', 0,-1);redis-> Zrange (' site ', 0,-1,true);//zrevrange key start Stop [withscores]--returns the member in the ordered set key, within the specified interval, where the member's position is decremented by the score value (from large to small) To arrange Redis->zrevrange (' site ', 0,-1); Redis->zrevrange (' site ', 0,-1,true);/***********connection (connection) ********** AUTH password--Password Authentication redis->auth (' 123456 ');//ping--View connection Status redis->ping ();//select index--switch to the specified database. The database index number is specified with a numeric value, with 0 as the starting index value, and No. 0 database Redis->select (1) is used by default, and/***********server (server) **********///time--returns the current server time. A list of two strings: the first string is the current time (represented in the UNIX timestamp format), and the second string is the number of microseconds redis->time () that have elapsed for the current second;//dbsize-– returns the number of keys for the current database redis- >dbsize ();//bgrewriteaof--uses aof for database Persistence redis->bgrewriteaof ();//save--saves data synchronously to disk redis->save ();// bgsave--data is saved asynchronously to disk Redis->bgsave ();//lastsave--returns the last Unix timestamp redis->lastsave () that successfully saved data to disk,//slaveof host port--selected from server $redis->slaveof (' 10.0.1.7 ', 6379);// flushall--clears the data for the entire Redis server (removes all keys from all databases) $redis->flushall ();//flushdb--clears all key$redis->flushdb () from the current database;// info [section]--Returns various information about the REDIS server and statistical values Redis->info ();
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.