I. key-value-related command keys: returns all keys meeting the given pattern using the expression *, which means to retrieve all keys using the expression mylist *, which means to retrieve all keyexists starting with mylist: confirm a key & nbs ..
I. key-value-related command keys: returns all keys meeting the given pattern using the expression *, which means to retrieve all keys using the expression mylist *, which means to retrieve all keyexists starting with mylist: confirm a key & nbs ..
I. Key-value related commands
Keys:
Returns all keys that meet the specified pattern.
Use the expression * to retrieve all keys.
Use the expression mylist * to retrieve all keys starting with mylist.
Exists:
Check whether a key exists.
Del:
Delete a key
Expire:
Set the expiration time of a key (unit: seconds)
In this example, we set the expiration time of the age key to 10 seconds, and then we continue to use ttl to get this
Key validity period.
Ttl return value:
If the key does not exist,-2 is returned.
-1 is returned if the key exists but the remaining survival time is not set.
Otherwise, in seconds, the remaining survival time of the key is returned.
Before Redis 2.8, when the key does not exist, or the key does not set the remaining survival time, the command returns-1.
Move:
Transfers keys in the current database to other databases
In this example, I first explicitly select database 0, then set a key in this database, and then we will
The key is moved from database 0 to database 1. Then we confirm that this key is not found in database 0, but it exists in database 1.
This key indicates that the transfer is successful.
Persist:
Remove the expiration time of a given key
In this example, we manually set the key that has not expired to an expiration date.
Randomkey:
Returns a random key of the key space.
Rename:
Rename key
Type:
Type of Return Value
Ii. Server commands
Ping:
Test whether the connection is alive
127.0.0.1: 6379> pingPONG127.0.0.1: 6379>
This indicates that the connection is successful.
Echo:
Print some content on the command line
127.0.0.1: 6379> echo 'Hello world' "hello world" 127.0.0.1: 6379>
Select:
Select a database. The Redis database number ranges from 0 ~ 15. We can select any database for data access.
If you select 16, an error is returned, indicating that there is no database numbered 16.
Dbsize:
Returns the number of keys in the current database.
127.0.0.1: 6379> dbsize (integer) 8127.0.0.1: 6379> The result shows that there are 8 keys in this database.
Info:
Obtain server information and statistics.
127.0.0.1: 6379> info # Serverredis_version: 2.8.2redis _ git_sha1: container: standaloneos: Linux 3.2.0-55-generic container: epollgcc_version: 4.6.3process _ id: 6756run_id: container: 6379uptime_in_seconds: 2606uptime_in_days: 0 hz: 10lru_clock: 246496config_file:/home/jane/soft/redis-2.8.2/redis. conf # labels: Memory: 0blocked_clients: 0 # Memoryused_memory: Memory: 790.41Kused _ memory_rss: Memory: 790.59Kused _ memory_lua: Memory: 2.69mem _ allocator: jemalloc-3.2.0 # labels: Memory: memory: usage: enabled:-1aof_enabled: enabled: Disabled:-enabled: OK # Statstotal_connections_received: 2total_commands_processed: Disabled: 0rejected_connections: 0sync_full: enabled: usage: 0keyspace_hits: 23keyspace_misses: Usage: 180 # Replicationrole: Usage: 0master_repl_offset: Usage: 0 # CPUused_cpu_sys: 0.18used _ cpu_user: 0.39used _ cpu_sys_children: 0.00used _ cpu_user_children: 0.00 # Keyspacedb0: keys = 8, expires = 0, avg_ttl = 0db1: keys = 1, expires = 0, avg_ttl = 0
This result is used to describe the basic information of the server, including the version and start time.
Monitor:
Real-time dump of received requests.
In a connection, enter monitor, wait for the request, and then enter the command in another connection:
Config get:
Obtain server configuration information.
In this example, we obtain the dir parameter configuration value. If you want to obtain the configuration value of all the parameter data, you only need
Run "config get *" to display all values.
Flushdb:
Delete all keys in the currently selected Database
Flushall:
Delete all keys in all databases.
This article is from "phper-a little bit every day ~" Blog, please keep this source