tencent cloud

Tencent Cloud Distributed Cache (Redis OSS-Compatible)

Release Notes and Announcements
Release Notes
Announcements
User Tutorial
Product Introduction
Overview
Product Strengths
Use Cases
Storage Engine
Product Series
Product Versions
Specifications and Performance
Read/Write Separation
Multi-AZ Deployment
Regions and AZs
Terms
Service Regions and Service Providers
Purchase Guide
Billing Overview
Pricing Center
Instance Purchasing
Renewal (Yearly/Monthly Subscription)
Refund (Yearly/Monthly Subscription)
Overdue Payments
Switching from Pay-as-You-Go to Yearly/Monthly Subscription
Getting Started
Quickly Creating an Instance
Connecting to an Instance (Redis/Valkey Edition)
Operation Guide
Operation Overview
Connecting to a Database Instance
Managing Instances
Upgrade Instance
Management Node (Redis/ValKey Edition)
Multi-AZ Deployment Management
Backup and Restoration
Managing Accounts
Parameter Configuration
Slow Query
Access Management
Network and Security
Monitoring and Alarms
Event Management (Redis/ValKey Edition)
Data Migration
Global Replication for Redis Edition
Database Audit
Performance Optimization
Sentinel Mode
Development Guidelines
Naming Rules
Basic Usage Guidelines
Design Principles of Key and Value
Command Usage Guidelines
Design Principles of Client Programs
Connection Pool Configuration
Command Reference
Command Reference Overview
Redis Edition and Valkey Edition Command Compatibility
Version Command Usage Differences
Differences Between the Proxy Architecture and Direct Connection Mode
More Command Operations (Redis/Valkey Edition)
Memcached Edition Command Compatibility
Practical Tutorial
Building TencentDB for Redis® Client Monitoring Based on Spring Boot
Redis Client Connection Configuration Policy and Practice
Global SCAN Guide for Cluster Architecture
Eliminating Instances Securely
Hot Key and Big Key
AZ Migration Scheme
Troubleshooting
Connection Exception
Exception Analysis and Solution of Redisson Client Timeout Reconnection
Performance Troubleshooting and Fine-Tuning
API Documentation
History
Introduction
API Category
Making API Requests
Instance APIs
Parameter Management APIs
Other APIs
Backup and Restoration APIs
Region APIs
Monitoring and Management APIs
Log APIs
Data Types
Error Codes
FAQs
General
Connection and Login
Purchase
Service Agreement
Service Level Agreement
Terms of Service
Glossary
Contact Us

Command Usage Guidelines

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2024-11-05 10:22:22

Checking N in the O(N) command

We recommend that you not excessively use these commands, including HGETALL, IRANGE, SMEMBERS, ZRANGE, and sinter . When using them, you need to specify the value of N.
The HSCAN, SSCAN, and ZSCAN commands in Redis can be used to traverse hash tables, sets, and sorted sets. These commands allow you to scan elements in the data set by using an iterator, without returning all elements at once like HGETALL, SMEMBERS, and ZRANGE. When using these commands, we recommend that you specify an appropriate COUNT parameter to avoid Redis performance degradation caused by excessive returned elements at once. Returning 1000 elements per traversal is preferred, but the specific quantity depends on the actual Redis situation. You can adjust it as needed.

Configuring disabled commands

Commands like KEYS, FLUSHALL, FLUSHDB are not allowed as the single-threaded CRedis takes a long time to execute them, which may cause command execution blocking. To address the potential blocking, we recommend that you use the scan command in a progressive manner or configure the disabled commands by disable-command-list parameter.
FLUSHDB and FLUSHALL: We recommend that you not use these two commands in the production environment, as they will clear all data in Redis.
KEYS: It returns all keys matched with specified mode. We recommend that you not use this command in the production environment, as it will block Redis server.
RANDOMKEY: It returns one key randomly. We recommend that you not use this command in the production environment, as it will block Redis server.
INFO: It returns various statistics and configuration items of the Redis server. We recommend that you not use this command in the production environment, as it will block Redis server.
CONFIG: It allows you to modify the configuration items of the Redis server. But use it with caution as it may cause server to crash.
SHUTDOWN: It allows you to disable the Redis server. We recommend that you not use this command in the production environment, as it will cause data loss.
BGREWRITEAOF and BGSAVE: It allows you to asynchronously rewrite the AOF and RDB files with a large amount of system resources being consumed. So use it with caution.

Using SELECT properly

Redis supports naming multiple databases with incrementing numbers. During the naming, you can change database at any time by using the SELECT command. The index number of each database is specified by a digit that starts from 0.
Redis supports multi-database operations. In standard edition, you can sort data using multiple databases; Even so, the business requests of Redis will be affected by operations on other databases as Redis is single-threaded. In cluster edition, we recommend that you prioritize using DB 0, as non-0 DBs do not support scaling. Additionally, when handling customer requests, it is not necessary to execute "SELECT 0" to reduce unnecessary interactions.

Using batch operations properly

RTT consumes much time when accessing Redis . If your application needs to perform a large number of GET or SET operations, you can use mget and mset for batch data operations to reduce the network RTT. The number of elements in MGET and MGET operations should not exceed 500. The greater this number is, the greater the impact will be in the case of jitter or scaling on the backend.
Native command: MEGET, MESETmset.
Non-native command: PIPELINE, which improves efficiency.
Note:
We recommend that you maintain the number of elements in each batch operation within 500 and check whether there is big key in the elements of batch operation.
The native command is an atom operation, while PIPELINEis not.
PIPELINE allows you to pack multiple commands,while the native command not.
PIPELINE must be supported on client and server.

Using no transactions

Redis has a limited transaction feature and does not support rollback. In addition, in the cluster edition of Redis, keys involved in a transaction operation must reside in the same slot.

Prerequisites for cluster edition using Lua

All keys should be passed using the KEYS array. When calling Redis commands in redis.call/pcall, the key must be in the KEYS array. Otherwise, the following error message will be returned: error,"-ERR bad lua script for redis cluster,all the keys that the script uses should be passed using the KEYS array".
For a Lua bootstrap action, the keys involved must be on the same Redis node. Otherwise, the following error message will be returned: error, "-ERR eval/evalsha command keys must in same slotrn".

MONITOR command

The MONITOR command has some impacts on the performance of Redis. In daily usage, it is used only for analyzing command execution and not for monitoring. We recommend that you enable it only in the case of troubleshooting or analysis, and disable it in time.

Prohibit setting Redis as message queue

Don't use Redis as a message queue; otherwise, you may encounter problems in capacity, network, efficiency, and feature.

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백