Skip to content

Latest commit

 

History

History
34 lines (23 loc) · 1.05 KB

File metadata and controls

34 lines (23 loc) · 1.05 KB

Cache utilities

Latest Stable Version Coverage Software License

This package provides small utilities for PSR cache implementations.

Installation

composer require cache/util:^1.0

Usage

The remember() helper reads a PSR-16 value or creates and stores it when the cache misses.

use function Cache\Util\SimpleCache\remember;

$result = remember(
    $cache,
    'report.monthly',
    3600,
    static fn () => buildMonthlyReport(),
);

Here, $cache implements Psr\SimpleCache\CacheInterface. The callback runs only when no cached value is available.

Contributing

Send pull requests to the main repository. Report issues on the GitHub issue tracker.