avoutic / web-framework-redis
Redis module for web-framework
Installs: 144
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/avoutic/web-framework-redis
Requires
- ext-redis: *
- avoutic/web-framework: ^10 || ^11
- cache/redis-adapter: ^1.1
Requires (Dev)
- phpstan/phpstan: ^2.0
README
This module provides Redis caching integration for WebFramework.
Requirements
- PHP 8.2 or higher
- Redis server
- WebFramework 8.x
Installation
Install via Composer:
composer require avoutic/web-framework-redis
Make sure the definitions file is included in your project by adding it to definition_files in your config.php file:
return [ 'definition_files' => [ '../vendor/avoutic/web-framework/definitions/definitions.php', '../vendor/avoutic/web-framework-redis/definitions/definitions.php', 'app_definitions.php', ], ];
Usage
The module provides Redis integration for WebFramework, enabling Redis caching. It implements the WebFramework Cache interface to cache data.
To use Redis for caching you need to add it in your PHP-DI definitions:
return [ Cache::class => DI\autowire(RedisCache::class), ];
Configuration
If you are using the definition from definitions/defitinions.php. You can just add the following redis.php to your auth config directory (config/auth):
<?php return [ 'hostname' => env('REDIS_HOSTNAME', 'localhost'), 'port' => env('REDIS_PORT', 6379), 'password' => env('REDIS_PASSWORD', '') ]
Features
- Redis-based caching implementation
- Support for cache tags
- Automatic instrumentation for performance tracking
- PSR-16 compliant cache interface
License
MIT License - see LICENSE file for details