CONFIG GET

Introduction and Use Case(s)

The CONFIG GET command in Redis is used to retrieve the current configuration parameters of the Redis server. This can be useful for monitoring, debugging, or auditing the server settings. Typical scenarios include checking the values of configurations like maxmemory, timeout, and loglevel.

Syntax

  1. CONFIG GET parameter

Parameter Explanations

  • parameter: The specific configuration setting you want to retrieve. You can use an exact parameter name (e.g., maxmemory) or a pattern with wildcards (e.g., *memory*).

Return Values

The command returns an array of key-value pairs representing the current configuration settings that match the given parameter.

Example:

For CONFIG GET maxmemory, it might return:

  1. 1) "maxmemory"
  2. 2) "0"

For CONFIG GET *memory*, it might return:

  1. 1) "maxmemory"
  2. 2) "0"
  3. 3) "maxmemory-samples"
  4. 4) "5"

Code Examples

  1. dragonfly> CONFIG GET maxmemory
  2. 1) "maxmemory"
  3. 2) "0"
  4. dragonfly> CONFIG GET *memory*
  5. 1) "maxmemory"
  6. 2) "0"
  7. 3) "maxmemory-policy"
  8. 4) "noeviction"
  9. 5) "maxmemory-samples"
  10. 6) "5"

Best Practices

  • Use specific parameters rather than patterns when possible to reduce the overhead on the server.
  • Regularly monitor critical configurations like maxmemory to ensure they align with your performance and storage requirements.

Common Mistakes

  • Using overly broad patterns might retrieve more data than necessary, causing unnecessary load on the server.
  • Forgetting that some configuration changes might require a server restart to take effect.

FAQs

What happens if I use a non-existent parameter?

The command will return an empty array if no matching configuration settings are found.

Can I use CONFIG GET to monitor runtime changes?

Yes, CONFIG GET can be run at any time to check the current values of the configuration parameters, making it useful for monitoring changes in real-time.