承接 samsmithkruz/redis-client-class 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

samsmithkruz/redis-client-class

最新稳定版本:1.0.1.1

Composer 安装命令:

composer require samsmithkruz/redis-client-class

包简介

A powerful and intuitive Redis client for PHP developers.

README 文档

README

Packagist Downloads GitHub issues GitHub forks GitHub stars

RedisClient is a developer-friendly PHP class that provides a clean and intuitive API for working with Redis. It covers all major Redis operations, including:

  • Basic Key-Value Operations: Insert, update, delete, select
  • Hashes: Hash insert, update, delete, select
  • Lists: Push, pop, range selection
  • Sets & Sorted Sets: Add, remove, get members, score-based retrieval
  • Transactions: Multi-exec transactional execution
  • Pub/Sub: Publish and subscribe to channels
  • Expirations & TTL: Set timeouts for keys
  • Advanced Features: Pipelines, scripting, streams, and more

🚀 Installation

Clone the repository:

git clone https://github.com/samsmithKruz/redis_client_class.git
cd redis-client

Ensure you have the Redis PHP extension installed. If not, install it:

sudo apt install php-redis  # For Linux
brew install redis          # For Mac

⚡ Usage

1️⃣ Initialize the RedisClient

require 'RedisClient.php';

$redis = new RedisClient(); // Default: 127.0.0.1:6379

2️⃣ Basic Key Operations

$redis->insert('username', 'john_doe', 3600); // Store for 1 hour
echo $redis->select('username'); // Output: john_doe
$redis->update('username', 'jane_doe');
$redis->delete('username');

3️⃣ Hash Operations

$redis->hash_insert('user:1', 'name', 'John Doe');
echo $redis->hash_select('user:1', 'name'); // Output: John Doe

4️⃣ List Operations

$redis->push('queue', 'task_1');
$redis->push('queue', 'task_2');
echo $redis->pop('queue'); // Output: task_2

5️⃣ Pub/Sub

$redis->publish('news', 'Breaking News: PHP is awesome!');
$redis->subscribe('news', function ($redis, $channel, $message) {
    echo "Received on $channel: $message";
});

6️⃣ Transactions

$redis->transaction(function ($tx) {
    $tx->set('balance', 1000);
    $tx->incrBy('balance', 500);
});

📜 Full Feature List

  • Basic Commands: insert(), update(), delete(), select(), select_all()
  • Hashes: hash_insert(), hash_select(), hash_delete(), hash_select_all()
  • Lists: push(), pop()
  • Sets: set_add(), set_remove(), set_members()
  • Sorted Sets: zadd(), zrem(), zrange(), zscore(), etc.
  • Pub/Sub: publish(), subscribe()
  • Expirations: set_expiration(), get_ttl()
  • Transactions: transaction()
  • Pipelines: pipeline()
  • Scripting: eval(), evalsha()
  • Streams: xadd(), xread(), xdel()

🛠️ Contributing

If you want to improve the library, feel free to:

  • Fork the repo
  • Create a feature branch
  • Submit a pull request

📜 License

This project is open-source and released under the MIT License.

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-01