Skip to content

PD\Redis is a PHP Redis client wrapper built on Predis, offering simplified Redis operations with automatic connection management.

License

Notifications You must be signed in to change notification settings

pardnchiu/PHP-Redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PD\Redis

PD\Redis is a PHP Redis client wrapper built on Predis, offering simplified Redis operations with automatic connection management.

tag size
version download

Features

  • Automatic connection management
  • Environment-based configuration
  • Persistent connection support
  • Automatic database selection
  • Built-in error handling
  • Connection state monitoring
  • Automatic cleanup on destruction

Key Capabilities

  • Simple get/set operations with database selection
  • Automatic connection retry mechanism
  • Expiration time management
  • Connection status checking
  • Environment variables configuration
  • Persistent connection support

Required Environment Variables

REDIS_HOST=localhost    # Required: Redis server host
REDIS_PORT=6379         # Required: Redis server port
REDIS_PASSWORD=secret   # Optional: Redis server password

How to Use

Install

composer require pardnchiu/redis
// Initialize Redis client
$redis = new PD\Redis();

// Set value with expiration
$redis->set(0, "user:123", "user_data", 3600); // db 0, expires in 1 hour

// Get value
$data = $redis->get(0, "user:123"); // from db 0

// Check connection status
if ($redis->isConnected()) {
    // Redis is connected and ready
}

License

This source code project is licensed under the MIT license.

Creator

邱敬幃 Pardn Chiu


©️ 2024 邱敬幃 Pardn Chiu

About

PD\Redis is a PHP Redis client wrapper built on Predis, offering simplified Redis operations with automatic connection management.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages