In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces what are the data type commands in redis, which can be used for reference by interested friends. I hope you can learn a lot after reading this article.
Redis is a database of key-value pairs. There are 5 main data types:
String type (string), hash type (hash), list type (list), collection type (set), ordered collection type (zset)
A few basic commands:
Function description keys * get all the keys of the current database exists key [key...] Determine whether the key exists and return the number. If key has the same number, it is also the superposition number del key [key.] Delete key, return the number of deletions type key gets impaired data type (string,hash,list,set,zset) flushall clear all databases config [get, set] redis configuration
-inf negative infinity
+ inf positive infinity
One: string type (string)
The string type is the most basic type of Redis, and it can store any kind of string. The other four types are different forms of string types.
The most basic command of function syntax: GET, SETGET key,SET key value value, if there are spaces, double quotation marks are required to distinguish between integer increments: INCRINCR key default value is 0, so first execute the command to get 1, not integer prompt error to increase the specified integer: INCRBYINCRBY key increment integer decrement: DECRDECR key default value is 0, so first execute the command to get-1 It is not the integer prompt error to reduce the specified integer: DECRBYDECRBY key increment increases the specified floating-point number: INCRBYFLOATINCRBYFLOAT key increment is similar to the INCR command, except that it can increment a double-precision floating-point number to the tail: the APPENDAPPEND key value redis client does not output the appended string, but the total length of the output string gets the string length: STRLENSTRLEN key returns 0 if the key does not exist, note that if Chinese is available, the Chinese length is 3 Redis uses UTF-8 encoding to obtain multiple key values: MGETMGET key [key.] For example: MGET key1 key2 sets multiple key values: MSETMSET key value [key value...] For example: MSET key1 1 key2 "hello redis" binary specified location value: GETBIT
GETBIT key offset for example: GETBIT key1 2, key1 returns 1 for hello, the returned value is only 0 or 1, and 0 when key does not exist or exceeds the actual length
Set the binary bit value: SETBITSETBIT key offset value, return the old value of this position is the number of 1 binary: BITCOUNTBITCOUNT key [start end], start, end for the start and end byte operations: BITOPBITOP operation destkey key [key...], operation supports AND, OR, XOR, NOT offset: BITPOSBITPOS key bit [start] [end]
Two: hash type (hash)
Function syntax sets a single: HSETHSET key field value, returns 1 if it does not exist, returns 0 if it exists, and sets multiple settings without update and insert: HMSETHMSET key field value [field value.] Read a single: HGETHGET key field, does not exist is to return nil to read multiple: HMGETHMGET key field [field.] Read all: HGETALLHGETALL key, return a list of fields and field values to determine whether the field exists: HEXISTSHEXISTS key field, return 1, no return 0 field does not exist assignment: HSETNXHSETNX key field value, unlike the hset command, set the value to increase the number when the key does not exist: HINCRBYHINCRBY key field increment, return the increased number, if it is not an integer, it will prompt you to delete the field in error: HDELHDEL key field [field.] Return the number of deleted fields only get the field name: HKEYSHKEYS key, all the field names of the return key only get the field value: HVALSHVALS key, return the number of all field value fields of the return key: HLENHLEN key, return the total number of fields
Three: list type (list)
Internally, it is implemented using a two-way linked list, so getting closer to both ends of the element is faster, but it is slower to access through the index.
Function syntax adds the left element: LPUSHLPUSH key value [value...], returns the total number of added list elements, adds the right element: RPUSHRPUSH key value [value...], returns the total number of list elements added, removes the first element on the left: LPOPLPOP key, returns the value of the removed element, removes the first element on the right: RPOPRPOP key, returns the number of removed element values list elements: LLENLLEN key, returns 0 if it does not exist. Redis reads off-the-shelf values directly, not by counting the number of list fragments: LRANGE
LRANGE key start stop, if start returns an empty list when it is later than stop, if 0-1 returns a positive number of the entire list: start starts the index value, and stop ends the index value (the index starts at 0) when the number is negative: for example, lrange num-2-1 indicates the second on the right, and-1 indicates the first on the right.
Delete the specified value: LREM
LREM key count value, which returns the number of deletions
Count > 0. Delete the elements whose previous count value is value from the left.
Count0, which returns the element count that is not duplicated by count in the collection
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.