Skillpedia
برمجة عامة48k · #5598

redis-cli

ما الذي تفعله

redis-cli هو سطر أوامر للتحدث مع قاعدة بيانات Redis مباشرة من حاسوبك. يتيح لك عرض البيانات المخزّنة فيها وتغييرها وإدارتها.

متى تستخدمها

  • ✓عندما تريد أن ترى ما هو مخزّن في مفتاح Redis محدد.
  • ✓عندما تريد إضافة قيمة لمفتاح Redis أو تعديلها.
  • ✓عندما تريد التحقق من أن Redis يعمل بشكل صحيح.

رابط المهارة

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

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/redis-cli/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“كيف أعرض قيمة المفتاح «user:123» في Redis؟”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

تكتب الأوامر في الطرفية كأنك تتحدث مع Redis. يمكن أن يعمل بالوضع المباشر (أمر واحد ثم يخرج) أو بالوضع التفاعلي (تبقى متصلًا).

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

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)

…
الأسئلة الشائعة

كيف أثبّت redis-cli؟

يمكنك تثبيته باستخدام مديري الحزم مثل Homebrew (macOS) أو apt (Ubuntu/Debian) أو yum (CentOS/RHEL). ويمكنك أيضًا استخدامه عبر Docker.

هل من الآمن كتابة كلمات المرور مباشرة في الأمر؟

لا يُنصح بذلك. في بيئة الإنتاج، استخدم متغير البيئة REDISCLI_AUTH بدلًا من كتابة كلمة المرور مباشرة، لأنها قد تُحفظ في السجل.

ما الأمر الذي أستخدمه لرؤية كل المفاتيح؟

أمر KEYS * قد يوقف الخادم في قواعد البيانات الكبيرة. في الإنتاج، من الأفضل استخدام أمر SCAN لعرض المفاتيح بأمان.

التفاصيل

الوصف الأصلي من المؤلف

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

الشعبية

نجوم GitHub
48k
الترتيب
#5598
الترخيص
MIT
آخر تحديث
15‏/10‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة