silviooosilva / cacheer-php
CacheerPHP is a minimalist package for caching in PHP, offering a simple interface for storing and retrieving cached data using multiple backends.
Requires
- php: >=8.0
- predis/predis: ^2.3
- vlucas/phpdotenv: ^5.6
Requires (Dev)
- phpunit/phpunit: ^11.2
This package is auto-updated.
Last update: 2025-06-17 14:34:00 UTC
README
CacheerPHP is a minimalist package for PHP caching. Now, in version 3.0.0, you get even more flexibility, support for multiple backends (files, database and Redis), as well as new features for monitoring, compression and encryption and a more robust API design.
Features
- Cache Storage and Retrieval: Support for file storage, databases (MySQL, PostgreSQL, SQLite) and Redis.
- Customizable expiration: Set the TTL (Time To Live) of the cache precisely.
- Cache cleaning and flushing: Support for manual and automatic cleaning (via
flushAfter
). - Namespace support: Organize your cache entries by category.
- Customized Data Output: Options to return data in
JSON
,Array
,String
orObject
. - Compression and Encryption: Reduce storage space and increase the security of cached data.
- Cache Statistics and Monitoring: Track hit and miss statistics and average read/write times (Coming Soon).
- Advanced Logging: Detailed monitoring of the operation of the caching system.
Installation
CacheerPHP 3.0.0 is available via Composer. Add the following line to your composer.json file:
"silviooosilva/cacheer-php": "^3.0"
Or run the command:
composer require silviooosilva/cacheer-php
IMPORTANT WARNING!!!
Don't forget to set your environment variables in the .env.example file.
Remember that they must be set in the .env file, not in .env.example. To do this, do the following on your command line:
cp .env.example .env
Documentation
- Storing and retrieving cached data
- Customizable cache expiration
- Cache flushing and cleaning
- Namespace support for cache organization
- Automatic cleaning of the
flushAfter
cache directory - API Response Cache
- Custom Data Output (
JSON
) - Custom Data Output (
Array
) - Custom Data Output (
String
) - Upgrade Guide for Version 2.0.0
- API Reference
- API Reference - Cache Functions
Several practical examples are also available in the Examples folder in the root of the project.
Compatibility
- PHP: 8.0 or higher.
- Database Drivers: MySQL, PostgreSQL, SQLite.
- Redis
Tests
To run the tests, go to the root of the project and type the command:
vendor/bin/phpunit