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.

v3.6.1 2025-06-14 15:40 UTC

README

Maintainer Packagist Dependency Version Latest Version Quality Score Packagist Downloads

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 or Object.
  • 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

  1. Storing and retrieving cached data
  2. Customizable cache expiration
  3. Cache flushing and cleaning
  4. Namespace support for cache organization
  5. Automatic cleaning of the flushAfter cache directory
  6. API Response Cache
  7. Custom Data Output (JSON)
  8. Custom Data Output (Array)
  9. Custom Data Output (String)
  10. Upgrade Guide for Version 2.0.0
  11. API Reference
  12. 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

Support:

silviooosilva