Getting Started with Redis action notes

Source: Internet
Author: User
Tags hash redis redis server firewall

Getting started with Redis action note

Upload unzip make to folder install to the specified folder makes Prefix=/usr/local/ridis install into/usr/local/ridis can see the bin directory inside there are REDIS-CLI and redis-service, etc. Into the/home/docker/redis/redis-4.0.1 (extract directory) assignment redis-conf file to the installation directory CP redis.conf/usr/local/ridis start Redis Server Enter: cd/usr/local/

Ridis execution:./bin/redis-server./redis.conf Start Client entry: Cd/usr/local/ridis execute:./bin/redis-cli off:./BIN/REDIS-CLI shutdown  String Command Note assignment: Set key value (similar to map) execution: Set ower Hulang (same key, different value overrides) Get: Get key returns if not present: (nil) Delete specified Key:del key del The Ower return value is a numeric type that indicates a few deletions: (integer) 1 getset key value first gets the value of the key, sets a new value for it getset name Hulang The original Zhangsan is changed to the Hulang return value is the key's The original value (Zhangsan) incr key increments the specified key by 1, if it does not exist, it is first defined and assigned a value of 0, and then increments the incr num get num result is: 1 if the key cannot be converted to a number, (error) ERR value is not an Integer or out of range DECR key specifies that the key is decremented if it does not exist, define and assign a value of 0 and then decrement if the key cannot be converted to a number, (error) ERR value is not a integer or out of R Ange Incrby key increment increments the value of the specified key by the specified number, if key does not exist, then the value of the initialization key is 0, and then the return value is the key increment value Decrby key decrement will specify the value of key Decrements by the specified number, if key does not exist, the value of initialize key is 0, the increment return value is the value after the key is decremented, append key value concatenation string, if the key exists, then append the value after the original value, if the key does not exist, re-create a key/alue returns the length of the string empty database: Flushd
B-Hash operation: Hset key Field Name field value Fields FirstName Value ... The return value is the number of fields added Hset student add Beijing email 123@qq.com corresponding Hget student email returns the value of the field assigned to multiple fields at once hmset student add Beijing E Mail 123@qq.com hmget Student Add email Remove multiple values at once hgetall key remove all fields Hdel key field name delete specified field del key delete all fields add test data hmset hu Lang name Hulang age QQ Wechar A123 e-mail 123@qq.com hincrby key field increment Hincrby Hulang age 2 Add a field of hash Adds the specified value, returns the Increment Hdecrby key field increment Hdecrby Hulang age 2 Determines if a field exists hexists Hulang girlfirend exists return 1, does not exist return 0 view hash
How many fields are included Hlen key return value is the number of fields view all field names Hkeys key view all field values hvals key centOS7 view port status: Firewall-cmd--state Reload Configuration (execute this command after adding a new rule) Firewall-cmd--reload permanently add ports (such as 6379) Firewall-cmd--add-port=6379/tcp--permanent shut down firewall systemctl stop Firewalld.servic E-View rule: iptables-l-n Native Test connection remote port (cmd) Telnet 192.168.43.108 6379 list Note: "Usage scenario: User timeline, published by Say, Circle of friends" add data: FromLeft to right Add Lpush key value, value value, add from right to left Rpush key value value value value get data: Lrange key start end from index to node The elements of the bundle index, out of range will isolate the existing elements Lpop key to remove and return to the leftmost element, the time complexity is O (1) Rpop key to remove and return the element at the far right, the time complexity of O (1) Llen key returns the length of the list key, the time complexity is O (1 ) LINDEX key index Returns the specified list item, not found returns nil index can be positive negative, negative number indicates from behind LSET key index value sets the list item on the specified index Linsert key before| After Pivot value inserts a list item before/after the specified element, successfully returning a new list length, with a time complexity of O (N) Lrem key count value (inefficient) from the value of the parameter count, removes the list item in the list that is equal to the parameter value count greater than 0 , search from table header to footer, remove up to count count less than 0, search from footer to header, remove up to count count equals 0, remove all list items with value = Return the number of items removed LTRIM key start stop to intercept a list, Only the elements within the specified index range are preserved, and the complexity of the other delete commands is O (N) rpoplpush resouce destination from resouce popup Add destination header rpoplpush List List loop queue, parameter is the same as A list Set basic Operation Sadd Key Member[member member member member member member] returns the number of elements newly added to the collection Srem key element[element element ] removes one or more elements, returns the number of elements that are present and removed Sismember key element checks whether a given element exists in the collection, there is a return of 1, there is no return 0 "usage scenario: whether the member determines before watching the video" SCard key returns the size of the collection Smem BERS key returns all elements contained in the collection "How many times, votes," SPOP keyRandomly remove an element (because it is unordered, so remove who is random) Srandmember key [count] randomly takes an array containing one or more elements, does not delete the note: When count is negative, an array is returned, and the elements in the array may appear multiple times. The length of the array is the absolute value of count "usage scenario: Weibo sweepstakes, Forward sweepstakes, etc." Sdiff key key [key ...] calculates the difference set for all given sets and returns the result Sdiffstore destkey key key [key ...] calculates the difference set for all given sets and stores the result to Destkey SINTER key Key calculates the intersection of all given sets and returns the result Sinterstore destkey key key [key ...] calculates the intersection of all given sets and stores the result in Destkey sunion Key key [key ...] computes the set of all sets and returns the result Sunionstore destkey key [key ...] calculates the set of all collections and stores them in the Destkey "usage scenario: Weibo's common concern, QQ common friends, online shopping products Brush Select" Ordered set Notes (soted Set/zset) to be continued ...
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.