The common commands of Redis are divided into two main parts, one is the key-value related command, the other is the server-related command1. Key-Value related commandsKeys * Take out all current keyexists name to see if n has name this keyDel name Delete key nameExpire Confirm 100 setting confirm this key100 second expiresTTL confirm gets the effective duration of this key confirmSelect 0 Choose to 0 datab
4 889 user4# Gets the foreign key but does not sort; Lets sort skip the sort operation by passing a non-existent key as a parameter to the by option(Sort uid by user_nick_* get # get user_level_* get user_name_*)# use hash tables as parameters for by and get(Hmset user_info_1 name U1 age 9)(Hmset user_info_2 name U2 age 7)(Hmset user_info_3 name U3 age Level 8)(Hmset user_info_4 name U4 age level 6)(Sort uid by User_info_*->level) # 4 2 3 1(Sort uid by User_info_*->level get User_info_*->name)
Redis provides rich commands for manipulating databases and various database types that can be used on Linux endpoints.1. Key-Value related commands(1)keysReturns all keys that satisfy a given parameterWith an expression *, the delegate takes out all keys(2)existsConfirm if a key exists1 means present, 0 means no(3)expireSet the expiration time for a key(4)move:T
Summary of 16 commands commonly used in Redis string type data
Description: String type is the simplest type, and a key corresponding to a value,string type is binary safe. A Redis string can contain any data, such as a JPG picture or a serialized object. Common methods:1, set Method:Value for set (1) Use set for nonexistent key:
The common commands of Redis are divided into two main parts, one is the key-value related command, the other is the server-related command
1. Key-Value related commands
Keys * Take out all current key
exists name to see if n has name this key
Del name Delete key name
Expire Confirm 100 setting confirm this key100 second expires
TTL confirm gets the effective dur
5. Basic Redis commands --- unordered set, redis command --- set1. Each element in the set is unique and has no order.2. Comparison between set and list
Set
List
Storage content
Up to 2 ^ 32-1 strings
Up to 2 ^ 32-1 strings
Orderliness
Unordered
Ordered
Uniqueness
Unique
Not unique
3. The set uses
add your own password after requirepass in the redis configuration file. Specify the configuration again at startup
File. After entering the client, we find that all operations can be entered, but all operations are rejected. Therefore, we need to authorize them and use the auth statement to keep up
Password. You can also enter the password when logging on to the client, for example, redis-
4. Basic Redis commands-list, basic redis-list1. The list type is implemented using a double linked list. Therefore, if you want to add elements to both ends, the time complexity is O (1 ), the faster the element gets closer to the two ends. However, the cost is that accessing elements through indexes is slow.2. the maximum number of fields that each key can hold
#日志级别, there are four kinds of debug,verbose,notice,warning logfile "" #定义日志路径, "" means default syslog-identredis #通过syslog-enabled to control Print to Syslog, this value specifies the log flag in the Syslog syslog-facilitylocal0 #指定syslog的设备, can be user or local0-local7 databases16 #设置数据库的总数量 # # #快照配置 save9001 # Indicates that every 15 minutes and at least 1 key changes will trigger a persistent save30010 #表示每5分钟且至少有10个key改变, trigger a persistent save6010000 # Indicates that there a
The list type in Redis is somewhat similar to an array in a programming language, and the list type, as shown in the following illustration, is actually a two-way linked list structure that controls the data in the list by Lpush, Lpop, Rpush, rpop commands, so the list type can be used as a stack, can also be used as a queue.
Redis Chain List List type
The effi
stored by key.
12
mset key value [key value ...] Set one or more key-value pairs at the same time.
13
msetnx key value [key value ...] Sets one or more key-value pairs at the same time, if and only if all of the given keys do not exist.
14
psetex key milliseconds value This command is similar to the Setex command, but it sets the lifetime of the key in milliseconds, rather than in s
Introduction:
Common commands
1. Start without Configuration
Src/redis-Server
2. Start with configuration
Src/redis-server redis. conf
3. Start with configuration and logs
Src/redis-server redis. conf 1>
; DEL bar tip:The parameters of the DEL command do not support wildcards , but we can combine the Linux pipeline and the Xargs command to remove all the rules that match the key. For example, to delete all the keys that start with "User:", you can execute redis-cli keys "user:*" | xargs redis-cli DEL. In addition, beca
before obtaining the value of mykey, and then the SET command is surrounded in the transaction, so that each connection can be effectively guaranteed before exec is executed, if the value of mykey obtained by the current connection is modified by the client of another connection, the exec command of the current connection will fail to be executed. In this way, the caller can determine whether the Val has been reset successfully after determining the return value.Note:
Because the watch comman
about slots configuration. >>> Check forOpen Slots ...>>>Check Slots Coverage ... [OK] All16384 slots covered. Connecting to Node127.0.0.1:7006: OK>>> Send CLUSTER MEET to Node127.0.0.1:7006To MakeItJoinThe cluster. [OK] New node added correctly. You can enter any machine to see if a new node has been added, and you will find that the node you just added does not have any hash slots hosted, because there is data in the wood. Adding the slave node only needs to add the--slave parameter[[Email p
Start Redis ServiceSrc/redis-server or Src/redis-server redis.confSrc/redis-server redis.conf 1>log.log 2>errlog.log1 is the standard output and 2 is the error outputRandomly start Redis as a Linux serviceVi/etc/rc.local, add code:/root/install/
).
The following is a detailed description of the commands for each of the data types.
Second, String type
A string type is the most basic data type in Redis, and he can store any form of string, including binary data. The string type is also the basis for four other data types. That is, the other four data types are made up of string types.
Common commands a
Start Redis ServiceSrc/redis-server or Src/redis-server redis.confSrc/redis-server redis.conf 1>log.log 2>errlog.log1 is the standard output and 2 is the error outputRandomly start Redis as a Linux serviceVi/etc/rc.local, add code:/root/install/
Start Redis ServiceSrc/redis-server or Src/redis-server redis.confSrc/redis-server redis.conf 1>log.log 2>errlog.log1 is the standard output and 2 is the error outputRandomly start Redis as a Linux serviceVi/etc/rc.local, add code:/root/install/
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.