{"id":49880013,"url":"https://github.com/pardnio/php-redis-cli","last_synced_at":"2026-05-15T13:40:36.592Z","repository":{"id":275483905,"uuid":"926218130","full_name":"pardnio/php-redis-cli","owner":"pardnio","description":"(PHP Libaray) Redis client wrapper","archived":false,"fork":false,"pushed_at":"2025-08-24T09:06:35.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-24T17:35:29.458Z","etag":null,"topics":["backend","pardnchiu","php","php-library","redis","wrapper-library"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pardnio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-02T20:27:25.000Z","updated_at":"2026-04-05T18:05:10.000Z","dependencies_parsed_at":"2025-08-24T14:43:13.944Z","dependency_job_id":"c3d4967a-e5a7-4920-8b39-992395fab384","html_url":"https://github.com/pardnio/php-redis-cli","commit_stats":null,"previous_names":["pardnchiu/php-redis","pardnio/php-redis","pardnltd-tools/php-redis","pardnchiu/php-redis-cli","pardnio/php-redis-cli"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/pardnio/php-redis-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnio%2Fphp-redis-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnio%2Fphp-redis-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnio%2Fphp-redis-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnio%2Fphp-redis-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pardnio","download_url":"https://codeload.github.com/pardnio/php-redis-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnio%2Fphp-redis-cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33068889,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","pardnchiu","php","php-library","redis","wrapper-library"],"created_at":"2026-05-15T13:40:36.371Z","updated_at":"2026-05-15T13:40:36.586Z","avatar_url":"https://github.com/pardnio.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Redis CLI\n\n\u003e Lightweight PHP Redis client supporting cache operations, automatic connection management, and complete Redis functionality.\u003cbr\u003e\n\u003e Built on native Redis extension, providing stable and reliable cache operation experience.\n\n[![packagist](https://img.shields.io/packagist/v/pardnchiu/redis-cli)](https://packagist.org/packages/pardnchiu/redis-cli)\n[![version](https://img.shields.io/github/v/tag/pardnchiu/php-redis-cli?label=release)](https://github.com/pardnchiu/php-redis-cli/releases)\n[![license](https://img.shields.io/github/license/pardnchiu/php-redis-cli)](LICENSE)\u003cbr\u003e\n[![readme](https://img.shields.io/badge/readme-EN-white)](README.md)\n[![readme](https://img.shields.io/badge/readme-ZH-white)](README.zh.md)\n\n- [Three Core Features](#three-core-features)\n  - [Automatic Connection Management](#automatic-connection-management)\n  - [Multi-Database Support](#multi-database-support)\n  - [Stable Connection](#stable-connection)\n- [Features](#features)\n- [Usage](#usage)\n  - [Installation](#installation)\n  - [Environment Configuration](#environment-configuration)\n  - [Basic Usage](#basic-usage)\n- [API Reference](#api-reference)\n  - [Basic Operations](#basic-operations)\n  - [Hash Operations](#hash-operations)\n  - [List Operations](#list-operations)\n  - [Set Operations](#set-operations)\n  - [Management Operations](#management-operations)\n- [Error Handling](#error-handling)\n- [License](#license)\n- [Author](#author)\n\n## Three Core Features\n\n### Automatic Connection Management\nIntelligent connection pool management, automatically establishes and maintains Redis connections, supports persistent connections for improved performance\n\n### Multi-Database Support\nFlexible database selection mechanism, supports Redis multi-database operations to meet different business scenario requirements\n\n### Stable Connection\nBuilt-in retry mechanism and error handling, ensuring reliability in unstable network environments\n\n## Features\n\n- **Environment Variable Configuration**: Flexible environment variable settings, supports multi-environment deployment\n- **Persistent Connections**: Uses persistent connections to improve performance and reduce connection overhead\n- **Automatic Retry**: Built-in retry mechanism handles network fluctuations and temporary connection failures\n- **Complete Redis Operations**: Supports Redis data types including strings, hashes, lists, sets, etc.\n- **Multi-Database Support**: Supports Redis multi-database operations, flexible management of different business data\n- **Security Authentication**: Supports password authentication to ensure connection security\n- **Stateless Design**: Automatic connection management and cleanup\n\n## Usage\n\n### Installation\n\n```shell\ncomposer require pardnchiu/redis-cli\n```\n\n### Environment Configuration\n\n```env\nREDIS_HOST=localhost      # Redis host address\nREDIS_PORT=6379           # Redis port\nREDIS_PASSWORD=your_pass  # Redis password (optional)\n```\n\n### Basic Usage\n\n```php\n\u003c?php\n\nuse pardnchiu\\RDB;\n\n// Initialize client\n$redis = new RDB();\n\n// Basic string operations\n$redis-\u003eset(0, \"user:123\", \"John Doe\", 3600);  // Set value with expiration\n$user = $redis-\u003eget(0, \"user:123\");            // Get value\n\n// Check connection status\nif ($redis-\u003eisConnected()) {\n    echo \"Redis connection is normal\";\n}\n\n// Counter operations\n$redis-\u003eincr(0, \"page_views\");\n$redis-\u003edecr(0, \"stock_count\");\n```\n\n## API Reference\n\n### Basic Operations\n\n- `get($db, $key)` - Get string value\n  ```php\n  $value = $redis-\u003eget(0, \"user:123\");\n  ```\n\n- `set($db, $key, $content, $expire = null)` - Set string value\n  ```php\n  $redis-\u003eset(0, \"session:abc\", $data, 1800);  // 30 minutes expiration\n  $redis-\u003eset(1, \"config:app\", $config);        // Never expires\n  ```\n\n- `exists($db, $key)` - Check if key exists\n  ```php\n  if ($redis-\u003eexists(0, \"user:123\")) {\n      echo \"User exists\";\n  }\n  ```\n\n- `delete($db, $key)` - Delete key\n  ```php\n  $redis-\u003edelete(0, \"temp:data\");\n  ```\n\n- `ttl($db, $key)` - Get expiration time\n  ```php\n  $seconds = $redis-\u003ettl(0, \"session:abc\");\n  ```\n\n- `keys($db, $pattern)` - Search key names\n  ```php\n  $userKeys = $redis-\u003ekeys(0, \"user:*\");\n  ```\n\n### Hash Operations\n\n```php\n// Set hash field\n$redis-\u003ehset(0, \"user:123\", \"name\", \"John Doe\", 3600);\n$redis-\u003ehset(0, \"user:123\", \"email\", \"john@example.com\");\n\n// Get hash field\n$name = $redis-\u003ehget(0, \"user:123\", \"name\");\n\n// Get all hash data\n$userData = $redis-\u003ehgetall(0, \"user:123\");\n```\n\n### List Operations\n\n```php\n// Push to list (left/right side)\n$redis-\u003elpush(0, \"tasks\", \"New Task\", 3600);\n$redis-\u003erpush(0, \"logs\", \"Log Message\");\n\n// Pop list elements\n$task = $redis-\u003elpop(0, \"tasks\");\n$log = $redis-\u003erpop(0, \"logs\");\n\n// Get list length\n$length = $redis-\u003ellen(0, \"tasks\");\n```\n\n### Set Operations\n\n```php\n// Add set members\n$redis-\u003esadd(0, \"tags\", \"php\", 3600);\n$redis-\u003esadd(0, \"tags\", \"redis\");\n\n// Remove set member\n$redis-\u003esrem(0, \"tags\", \"old_tag\");\n\n// Get all members\n$tags = $redis-\u003esmembers(0, \"tags\");\n\n// Check member existence\nif ($redis-\u003esismember(0, \"tags\", \"php\")) {\n    echo \"Contains PHP tag\";\n}\n\n// Set operations\n$common = $redis-\u003esinter(0, [\"tags:user1\", \"tags:user2\"]);  // Intersection\n$all = $redis-\u003esunion(0, [\"tags:user1\", \"tags:user2\"]);     // Union\n$diff = $redis-\u003esdiff(0, [\"tags:user1\", \"tags:user2\"]);     // Difference\n```\n\n### Management Operations\n\n```php\n// Batch operations\n$values = $redis-\u003emget(0, [\"key1\", \"key2\", \"key3\"]);\n$redis-\u003emset(0, [\"key1\" =\u003e \"value1\", \"key2\" =\u003e \"value2\"]);\n\n// Numeric operations\n$redis-\u003eincr(0, \"counter\");         // Increment by 1\n$redis-\u003edecr(0, \"stock\");           // Decrement by 1\n$redis-\u003eappend(0, \"log\", \"New content\"); // Append string\n\n// Clear database\n$redis-\u003eflushdb(0);\n\n// Get server info\n$info = $redis-\u003einfo();\n```\n\n## Error Handling\n\n```php\ntry {\n    $redis = new RDB();\n    \n    // Redis operations\n    $result = $redis-\u003eset(0, \"user:123\", $userData, 3600);\n    \n    if ($result) {\n        echo \"Data saved successfully\";\n    } else {\n        echo \"Data save failed\";\n    }\n    \n} catch (\\Exception $e) {\n    // Connection error handling\n    error_log(\"Redis error: \" . $e-\u003egetMessage());\n    \n    if (strpos($e-\u003egetMessage(), \"Connection refused\") !== false) {\n        echo \"Redis server is not running\";\n    } elseif (strpos($e-\u003egetMessage(), \"Authentication\") !== false) {\n        echo \"Redis authentication failed, please check password\";\n    } else {\n        echo \"Redis operation exception, please try again later\";\n    }\n}\n```\n\n### Connection Status Check\n\n```php\n$redis = new RDB();\n\n// Check connection status\nif (!$redis-\u003eisConnected()) {\n    // Handle connection failure\n    error_log(\"Redis connection failed, using fallback solution\");\n    \n    // Can use other cache solutions or directly query database\n    return $this-\u003efallbackCache($key);\n}\n\n// Normal Redis usage\n$data = $redis-\u003eget(0, $key);\n```\n\n### Performance Monitoring\n\n```php\n// Monitor connection status\n$info = $redis-\u003einfo();\nif ($info) {\n    $connectedClients = $info['connected_clients'] ?? 0;\n    $usedMemory = $info['used_memory_human'] ?? '0B';\n    \n    error_log(\"Redis status - Connections: {$connectedClients}, Memory usage: {$usedMemory}\");\n}\n```\n\n## License\n\nThis project is licensed under the [MIT](LICENSE) License.\n\n## Author\n\n\u003cimg src=\"https://avatars.githubusercontent.com/u/25631760\" align=\"left\" width=\"96\" height=\"96\" style=\"margin-right: 0.5rem;\"\u003e\n\n\u003ch4 style=\"padding-top: 0\"\u003e邱敬幃 Pardn Chiu\u003c/h4\u003e\n\n\u003ca href=\"mailto:dev@pardn.io\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://pardn.io/image/email.svg\" width=\"48\" height=\"48\"\u003e\n\u003c/a\u003e \u003ca href=\"https://linkedin.com/in/pardnchiu\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://pardn.io/image/linkedin.svg\" width=\"48\" height=\"48\"\u003e\n\u003c/a\u003e\n\n***\n\n©️ 2024 [邱敬幃 Pardn Chiu](https://pardn.io)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpardnio%2Fphp-redis-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpardnio%2Fphp-redis-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpardnio%2Fphp-redis-cli/lists"}