Skip to content

Light, simple and standalone PHP in-file caching class

License

Notifications You must be signed in to change notification settings

flightphp/cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

75fe4fc · Feb 21, 2025

History

18 Commits
Feb 21, 2025
Nov 26, 2017
Feb 21, 2025
Feb 21, 2025
Nov 26, 2017
Feb 21, 2025
Feb 21, 2025
Feb 21, 2025
Feb 21, 2025
Feb 21, 2025
Feb 21, 2025
Feb 21, 2025
Feb 21, 2025

Repository files navigation

Cache Latest Stable Version License

Light, simple and standalone PHP in-file caching class

Advantages

  • Light, standalone and simple
  • All code in one file - no pointless drivers.
  • Secure - every generated cache file have a php header with die, making direct access impossible even if someone knows the path and your server is not configured properly
  • Well documented and tested
  • Handles concurrency correctly via flock
  • Supports PHP 7.4+
  • Free under a MIT license

Requirements and Installation

You need PHP 7.4+ for usage

Require with composer:
composer require flightphp/cache

Usage

<?php
use flight\Cache;
require_once __DIR__ . "/vendor/autoload.php";

$cache = new Cache();

$data = $cache->refreshIfExpired("simple-cache-test", function () {
    return date("H:i:s"); // return data to be cached
}, 10);

echo "Latest cache save: $data";

See examples for more