Redis introduction and Common commands, redis introduction Common commandsRedis introduction and Common commands
Redis is an open-source, BSD-based, advanced key-value cache and storage (store) system. Redis keys include string, h
Common Redis commands and redis commands
1 Create-store or not-View-delete
Set name maojun; exists name; get name; del name;
2. serialization record
Set name maojun; exists name; dump name; the client is logged out, and exists name and name still exist.
3. Set the survival time for the key-Modify the survival time
Set
Summary of common Redis commands and common redis commandsService command:• BGREWRITEAOF asynchronously rewrite the append object• BGSAVE asynchronously saves the dataset to the disk• Client kill ip: port closes CLIENT Connection• Client list to obtain the CLIENT connection LIST• Client pause timeout pause client commands
; Rpop Key
Here is a good understanding, respectively, from the left pop-up, from the right pop-up, the return value is a pop-up value. (pop-up means to remove the value and return the value)
Combined with the above four commands, you can implement stacks and queues.
Stacks: Lpush and Lpop or using Rpush and Rpop.
Queues: Lpush and Rpop or using Rpush and Lpop.
3, get the number of elements in the list Shell Redisgt;llen Key
1
;delete (Array (' Key3 ', ' key4 ', ' key5 '));TtlGet a key to the time of survivalPersistRemove key for lifetime expirationIf the key expires true if it does not expire falseMset (Redis version 1.1 or above only available)Assign values to multiple keys at the same time$redis->mset (Array (' key0 ' = ' value0 ', ' key1 ' = ' value1 '));Multi, exec, discardEnter or exit Transaction modeParameter optional
results are stored in the Resultkey sequence (List)
Persistent control
Save synchronize data to disk
Bgsave asynchronously saves data to disk
Lastsave returns the Unix timestamp that was last successfully saved to disk
SHUTDOWN sync to the server and shut down the Redis server (save+quit)
Bgrewriteaof the log file when it is too long
Remote CONTROL command
Info provides information and statistics about the server
Monitor to output all incoming reques
of Redis with a single command. The Redis commands are as follows:Connection controlQUIT Close ConnectionAUTH (when enabled only) Simple password verificationFor all types of commandsEXISTS key determines whether a key exists; returns 1; otherwise returns 0;DEL key Deletes a key, or a series of Key;del Key1 Key2 Key3 Key4Type key returns the data type of a key e
synchronously to disk, and then close the serviceTen One Remote Service Control A - Info: Provide information and statistics about the server - Monitor: Live dump of received requests the slaveof: Changing Replication policy settings - Config: Configure the Redis server at run time - - commands for the value operation + - exists (key): Verify that a key exists + del (key): Delete a key A type (key)
8. Basic Redis commands-management-persistence-RDB, redis-rdb1. Redis supports two methods of Persistence: RDB and AOF. It can be used separately or in combination.2. The rdb a and RDB modes are the default persistence methods adopted by Redis, which are completed through sn
7. Basic Redis commands-task queue and redis queue1. Advantages: loose coupling is easy to expand, and consumers can expand multiple servers.2. LPUSH RPOP3. The BRPOP command is similar to RPOP. The only difference is that when there are no elements in the list, the BRPOP command will always block the link and know that new elements are added.4. If the value of B
landing: Sudo/opt/java/redis/bin/redis-cli-a Primos or enter the future auth Primos and then you can operate at random2, master-slave copy to do this operation when I prepared two virtual machines, IP is 192.168.15.128 and 192.168.15.133 through master-slave replication can allow multiple slave server has the same database copy with master server specific configuration is Slave configuration slave slaveof
introduction of common data types:
There are five data types used by Redis: String,hash,list,set,zset (sorted set). 1. String Type
String is the simplest type, and a key corresponds to a value
of type string with a maximum of 1G.
A string type can be treated as an integer, allowing the "INCR" command family to operate (Incrby, DECR, Decrby), in which case the value of the integer is limited to 64-bit signed numbers. The
separate element types contai
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
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
Reproduced in: http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/117.html?14558602361. Redis View all current keyThe code is as follows:KEYS *2. View the current Redis configuration information ?The code is as follows:CONFIG GET *3. misconf Redis is configured to save the RDB snapshots, but was currently not ab
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.