In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "what are the common methods for php to operate redis". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1,connect
Description: the instance is connected to a Redis.
Parameter: host: string,port: int
Return value: BOOL successful return: TRUE; failed return: FALSE
Example:
The copy code is as follows:
2,set
Description: set values for key and value
Parameter: Key Value
Return value: BOOL successful return: TRUE; failed return: FALSE
Example:
The copy code is as follows:
3,get
Description: gets the value about the specified key
Parameter: key
Return value: string or BOOL returns FALSE if the key does not exist. Otherwise, the value corresponding to the specified key is returned.
Example:
The copy code is as follows:
4,delete
Description: delete the specified key
Parameters: a key, or an uncertain number of parameters, each key array: key1 key2 key3... KeyN
Return value: number of items deleted
Example:
The copy code is as follows:
5,setnx
Description: if the key does not exist in the database, set the key parameter
Parameter: key value
Return value: BOOL successful return: TRUE; failed return: FALSE
Example:
The copy code is as follows:
6,exists
Description: verify that the specified key exists
Parameter key
Return value: Bool successful return: TRUE; failed return: FALSE
Example:
The copy code is as follows:
7,incr
Description: numerically incremented storage key value key.
Parameter: key value: the value to be added to the key
Return value: INT the new value
Example:
The copy code is as follows:
8,decr
Description: digitally decreasing stores key values.
Parameter: key value: the value to be added to the key
Return value: INT the new value
Example:
The copy code is as follows:
9,getMultiple
Description: gets the values of all specified keys. If one or more keys do not exist, the value of the key in the array is false
Parameters: a list array containing key values
Return value: returns an array of values for all keys
Example:
The copy code is as follows:
10,lpush
Description: add a string value from the header of the list. If the key does not exist, the list is created. If the key exists and it is not a list, return FALSE.
Parameter: key,value
Return value: array length returned successfully, false failed
Example:
The copy code is as follows:
11,rpush
Description: a string value is added at the end of the list. If the key does not exist, the list is created. If the key exists and it is not a list, return FALSE.
Parameter: key,value
Return value: array length returned successfully, false failed
Example:
The copy code is as follows:
12,lpop
Description: returns and removes the first element of the list
Parameter: key
Return value: the value of the first element is returned successfully, and false is returned for failure.
Example:
The copy code is as follows:
13,lsize,llen
Description: the length of the returned list. If the list does not exist or is empty, the command returns 0. If the key is not a list, the command returns FALSE.
Parameter: Key
Return value: array length returned successfully, false failed
Example:
The copy code is as follows:
14,lget
Description: returns the element specified by the specified key stored in the list. 0 the first element, 1 the second... The last element of-1, the penultimate element of-2. Returns FALSE if the wrong index or key does not point to the list.
Parameter: key index
Return value: the value of the specified element was returned successfully, but failed false
Example:
The copy code is as follows:
15,lset
Description: assigns a new value to the index specified in the list, and returns false if it does not exist.
Parameter: key index value
Return value: true for success, false for failure
Example:
The copy code is as follows:
16,lgetrange
Description:
Returns the specified element, lGetRange (key, start, end), stored from start to end in the list of specified keys in this area. 0 the first element, 1 the second element. The last element of-1, the penultimate element of-2.
Parameter: key start end
Return value: the searched value was returned successfully, but failed false
Example:
The copy code is as follows:
17,lremove
Description: removes count matching values from the list from the header. If count is zero, all matching elements are deleted. If count is negative, the content is deleted from the tail.
Parameter: key count value
Return value: the number of deletions returned successfully, but failed false
Example:
The copy code is as follows:
18,sadd
Description: add a value to a Key. If the value is already in the Key, FALSE is returned.
Parameter: key value
Return value: true for success, false for failure
Example:
The copy code is as follows:
19,sremove
Description: delete the value specified in Key
Parameter: key member
Return value: true or false
Example:
The copy code is as follows:
20,smove
Description: move value from Key1 to Key2
Parameter: srcKey dstKey member
Return value: true or false
Example
The copy code is as follows:
21,scontains
Description: checks whether the specified value exists in the collection.
Parameter: key value
Return value: true or false
Example:
The copy code is as follows:
22,ssize
Description: returns the number of values stored in the collection
Parameter: key
Return value: number of arrays returned successfully, failed 0
Example:
The copy code is as follows:
23,spop
Description: randomly removes and returns a value in key
Parameter: key
Return value: the deleted value was returned successfully, but failed false
Example:
The copy code is as follows:
24,sinter
Description: returns an intersection of all specified keys. If only one key is specified, this command generates members of the collection. Returns FALSE if a key does not exist.
Parameters: key1, key2, keyN
Return value: array intersection is returned successfully, false is failed
Example:
The copy code is as follows:
25,sinterstore
Description: execute the sInter command and store the results in the newly created variable.
Parameters:
Key: dstkey, the key to store the diff into.
Keys: key1, key2... KeyN. Key1..keyN are intersected as in sInter.
Return value: successful return, number of intersections, failed false
Example:
The copy code is as follows:
26,sunion
Description:
Returns a union of all specified keys
Parameters:
Keys: key1, key2, … , keyN
Return value: the merged set was returned successfully, but failed false
Example:
The copy code is as follows:
27,sunionstore
Description: execute the sunion command and store the results in the newly created variable.
Parameters:
Key: dstkey, the key to store the diff into.
Keys: key1, key2... KeyN. Key1..keyN are intersected as in sInter.
Return value: successful return, number of intersections, failed false
Example:
The copy code is as follows:
28,sdiff
Description: returns results that exist in the first collection and do not exist in all other collections
Parameter: Keys: key1, key2, … , keyN: Any number of keys corresponding to sets in redis.
Return value: array returned successfully, false failed
Example:
The copy code is as follows:
29,sdiffstore
Description: execute the sdiff command and store the results in the newly created variable.
Parameters:
Key: dstkey, the key to store the diff into.
Keys: key1, key2, … , keyN: Any number of keys corresponding to sets in redis
Return value: number returned successfully, false failed
Example:
The copy code is as follows:
30,smembers, sgetmembers
Description:
Returns the contents of the collection
Parameter: Key: key
Return value: An array of elements, the contents of the set.
Example:
The copy code is as follows:
This is the end of the content of "what are the common methods for php to operate redis". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.