Redis Server Operations

Source: Internet
Author: User
Tags log log redis server

"Redis Server Operations "

1. Time

Returns the current server time.

2,dbsize

Returns the number of keys for the current database.

3,Lastsave

Returns the time that the most recent Redis successfully saved data to disk, expressed in the UNIX timestamp format.

4,BGSAVE

Asynchronously (asynchronously) saves data from the current database to disk in the background.

The BGSAVE command returns immediately after execution, OK then Redis fork out a new subprocess, the original Redis process (the parent process) continues to process the client request, and the child process is responsible for saving the data to disk and then exiting.

The client can view the relevant information through the Lastsave command and determine whether the BGSAVE command is successful.

5,flushdb

Clears all keys in the current database.

This command never fails.

6,Flushall

Clears the data for the entire Redis server (all keys for all databases are deleted).

This command never fails.

7.slowlog subcommand [argument]

What is Slowlog

Slow log is a log system used by Redis to record query execution times.

Query execution time refers to not including IO operations such as client response (talking), sending replies, and simply the time spent executing a query command.

In addition, the slow log is stored in memory and reads and writes very quickly, so you can use it with confidence, without worrying about the speed of Redis due to opening slow log.

Set Slowlog

The behavior of Slow log is specified by two configuration parameters (config parameter) and can be dynamically modified by overwriting redis.conf files or by using CONFIG GET and CONFIG SET commands.

The first option is slowlog-log-slower-than that it determines how many microseconds (microsecond,1 seconds = 1,000,000 microseconds) of execution time are recorded for queries.

For example, executing the following command will let slow log log all queries that have a query time greater than or equal to 100 microseconds:

CONFIG SET slowlog-log-slower-than 100

The following command logs all queries that have a query time greater than 1000 microseconds:

CONFIG SET slowlog-log-slower-than 1000

Another option is slowlog-max-len that it determines how many logs slow log can hold, slow log itself is a FIFO queue, and when the queue size is exceeded, the oldest slowlog-max-len log is deleted, and the latest log is added to the slow log, and so on.

The following command allows slow log to save up to 1000 logs:

CONFIG SET slowlog-max-len 1000

Redis Server Operations

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.