Chuyển đến nội dung
Skillpedia
Lập trình chung48k · #5598

redis-cli

Skill này làm gì

redis-cli là công cụ để trò chuyện trực tiếp với cơ sở dữ liệu Redis từ máy tính. Nó cho phép bạn xem, thay đổi hoặc quản lý dữ liệu được lưu trong Redis.

Khi nào nên dùng

  • ✓Khi bạn cần xem những gì được lưu trong một key Redis cụ thể.
  • ✓Để thêm hoặc sửa giá trị của một key Redis.
  • ✓Để kiểm tra xem Redis có hoạt động đúng không.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/redis-cli/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/redis-cli/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Làm sao để xem giá trị của key “user:123” trong Redis?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Bạn gõ lệnh trong terminal như thể đang nói chuyện với Redis. Công cụ có thể chạy ở chế độ trực tiếp (một lệnh rồi thoát) hoặc chế độ tương tác (bạn tiếp tục trò chuyện với nó).

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

redis-cli — Redis Command Line Interface

When to Use

Use this skill when you need redis command-line interface (redis-cli) reference and usage guide. Use this skill whenever the user mentions redis-cli, Redis CLI, or any task involving querying, inspecting, debugging, or managing Redis from the command line. Triggers on key/value reads and writes, SCAN or keyspace...

redis-cli is the primary command-line tool for interacting with Redis. It supports two modes: command-line execution (run a command and exit) and interactive mode (a REPL with tab completion, history, and hints). It also provides special modes for monitoring, latency analysis, key space scanning, and data import/export.

Official resources: Redis CLI Docs | Commands | Download

Prerequisites

# Check if redis-cli is installed
redis-cli --version

# Install options:

# macOS (Homebrew)
brew install redis

# Ubuntu / Debian
sudo apt install redis-tools

# CentOS / RHEL
sudo yum install redis

# Alpine
apk add redis

# Build from source (binary only)
make redis-cli
# Binary at: src/redis-cli

# Docker (no installation needed)
docker run -it --rm redis redis-cli -h <host> -p <port> PING

Security Considerations

IMPORTANT: Redis provides powerful operations that can irreversibly modify or delete data. Pay close attention to the following safety guidelines:

  • Never pass passwords via -a in production — visible in shell history and process listings. Use REDISCLI_AUTH environment variable instead.
  • KEYS * blocks the server on large databases — always use SCAN in production code.
  • MONITOR logs all commands including sensitive data — use cautiously, and never for extended periods on production servers.
  • FLUSHALL / FLUSHDB are irreversible — verify target database with CLIENT LIST or INFO keyspace first.
  • --rdb transfer during write operations may produce inconsistent snapshots on busy servers.

Quick Reference

Connection

# Basic connection (default: 127.0.0.1:6379)
redis-cli
redis-cli -h redis15.localnet.org -p 6390 PING

# With password (prefer REDISCLI_AUTH env var for security)
redis-cli -a myUnguessablePazzzzzword123 PING

# URI connection
redis-cli -u redis://user:password@host:port/dbnum PING

# TLS
redis-cli --tls --cacert /path/to/ca.crt -h redis.example.com PING

# Specific database
redis-cli -n 2 DBSIZE

# IPv4/IPv6 preference
redis-cli -4 PING   # prefer IPv4
redis-cli -6 PING   # prefer IPv6

Command-Line vs Interactive Mode

# Command-line mode: execute one command and exit
redis-cli INCR mycounter
redis-cli GET mykey

# Interactive mode: type commands at the prompt
redis-cli
127.0.0.1:6379> PING
PONG
127.0.0.1:6379> SELECT 2
OK
127.0.0.1:6379[2]> DBSIZE
(integer) 1

The prompt shows host:port[db]. Use CONNECT <host> <port> to switch instances interactively.

Data Query Cheat Sheet

String operations (O(1)):

GET key                        # Get value
SET key value [NX|XX] [EX sec|PX ms|KEEPTTL]  # Set with conditions/TTL
SET key value GET              # Set new, return old value
GETSET key newvalue            # [Use SET key value GET instead]
MGET key1 key2 ...             # Get multiple values
INCR key                       # Increment integer (+1)
INCRBY key 10                  # Increment by amount
STRLEN key                     # String length
GETRANGE key 0 50              # Substring

Hash operations:

HGET key field                 # Get field value            O(1)
HMGET key f1 f2                # Get multiple fields        O(N)
HGETALL key                    # Get all fields/values      O(N)
HKEYS key                      # Get all field names        O(N)
HLEN key                       # Number of fields           O(1)
HEXISTS key field              # Check field exists         O(1)
HSCAN key 0 [MATCH pat]        # Iterate hash fields        O(1) per call

List operations:

LRANGE key 0 -1                # Get all elements           O(N)
LLEN key                       # List length                O(1)
LINDEX key 0                   # Get by index               O(N)
LPOS key value                 # Find element position      O(N)

Set operations:

SMEMBERS key                   # Get all members            O(N)

…
Câu hỏi thường gặp

Làm sao để cài redis-cli?

Bạn có thể cài bằng các trình quản lý gói như Homebrew (macOS), apt (Ubuntu/Debian) hoặc yum (CentOS/RHEL). Bạn cũng có thể dùng qua Docker.

Có an toàn không khi gõ mật khẩu trực tiếp trong lệnh?

Không nên. Với production, hãy dùng biến môi trường REDISCLI_AUTH thay vì gõ mật khẩu trực tiếp, vì mật khẩu có thể bị lưu trong lịch sử lệnh.

Dùng lệnh nào để xem tất cả key?

Lệnh `KEYS *` có thể làm treo máy chủ với cơ sở dữ liệu lớn. Trong production, nên dùng lệnh `SCAN` để liệt kê key an toàn hơn.

Chi tiết

Mô tả gốc của tác giả

Redis command-line interface (redis-cli) reference and usage guide. Use this skill whenever the user mentions redis-cli, Redis CLI, or any task involving querying, inspecting, debugging, or managing Redis from the command line.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#5598
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự