In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Summary of common data types in redis
Redis stores data in the form of key-value pairs key-value, and there are five types of data stored in String,List,Set,Map and ordered collections
Most of the commands for these five data types are similar, often confused and summed up in their spare time.
Type 1: String
1append key value
If key exists, append value to the original value
If it does not exist, create a new one with key as the key and value as the value.
2get key
Returns the string associated with key. Return nil if key does not exist
3bitcount key
Returns the number of bits in a given string that are set to 1
4decr key
Minus one of the numeric values stored in key
5decrby key num
The value stored in key minus num
6getbit key offset
Gets the bit on the specified offset for the string value stored by key
7getrange key start end
Returns the string between start and end stored in key
8getset key value
Sets the value of the given key to value and returns the original value of key
9incr adds one of the numeric values stored in key
10incrby key num
Add the value stored in key to num
11mget key1 key2...
Returns the values of all given key
12mset key1 value1 key2 value2...
Set multiple key-value pairs at the same time
13setex key seconds value
Set the key value key-value pair and set the lifetime of key
14strlen key
Returns the length of the value stored by key
Type 2: HASH (hash), also known as hash
1hset key-name key value
Set a bunch of key-value pairs key value in the hash table named key-name
2hsetnx key-name key value
Set a bunch of key-value pairs key value in the hash table named key-name if and only if key does not exist.
3hmset key-name key1 value1 key2 value2...
Set multiple key-value pairs for a hash named key-name.
4hget key-name key
Get the value named key in the key-name hash table
5hmget key-name key1 key2...
Get the key key1 key2 in the hash table named key-name. Value of
6hgetall key-name
Get all the key-value pairs contained in the hash
7hvals key-name
Gets all the values contained in the hash
8hkeys key-name
Gets all the keys contained in the hash
9hlen key-name
Returns the number of key-value pairs contained in the hash
10hdel key-name key1 key2
Delete one or more values in the hash
11hincrby key-name key increment
Add the value stored in the key key to the integer increment in the hash named key-name
Type 3: list (List)
1lpop key-name
Remove and return the header element of the list key (the leftmost element)
2rpop key-name
Remove and return the tail element of the list key (the rightmost element)
3lpush key-name value1 value2
Push one or more values into the header of the list (leftmost)
4rpush key-name value1 value2...
Push one or more values to the end of the list (rightmost)
5lpushx key-name value
Insert the value value into the header of the list key-name if and only if key exists and is a list
6rpushx key-name value
Insert the value value at the end of the list key-name if and only if key exists and is a list
7ltrim key start stop
Prune a list to retain the elements in the specified range, and elements that no longer specify the interval will be deleted.
8lset key-name index value
Set the value of index in the table below the key-name list to value
9lrange key-name start stop
Returns the elements in the specified range in the list key-name.
10llen key-name
Returns the length of the list key-name
Type 4: collection (SET)
1sadd key-name item1 item2...
Add one or more elements to the collection key-name
2srem key-name item1 item2
Remove one or more elements from the collection key-name
3scard key-name
Returns the number of all elements contained in the collection
4sismember key-name item
Determine whether the item element is a member of the collection key-name
5smembers key-name
Returns all members of the key-name
6sdiff key-name1 key-name2..
Returns the element after the difference operation between the first set and the other sets
7sinter key-name1 key-name2
Returns elements that exist in all sets at the same time, intersection operation
8sunion key-name1 key-name2...
Returns elements that exist in at least one set, union operation
9smove key-name1 key-name2 item
Move item elements from the key-name1 collection to the key-name2 collection
10spop key-name
Removes and returns a random element in the key-name collection
Type 5: ordered set
1zadd key-name score1 member1 [score2 member2]
Add one or more member elements and their score score to the key-name collection
2zrem key-name member1 member2...
Remove one or more members of an ordered set and key-name
3zcard key-name
Returns the number of elements in an ordered collection
4zrank key-name member
Returns the ranking of element member in an ordered set
5zcount key-name min max
Returns the number of members whose score is between min max
6zscore key-name member
Returns the score of the member member in the key-name ordered set
7zrange key-name start stop
Returns the elements in the ordered collection that rank between start stop.
8zincrby key-name increment member
Add an incremental increment to the member member in the ordered collection key-name.
If you have different opinions, you are welcome to discuss common progress with each other.
References include josiah L. Carlson redis in action
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.