leafs/cache

Leaf PHP cache module

dev-main 2025-09-05 20:01 UTC

This package is auto-updated.

Last update: 2025-09-05 20:02:33 UTC


README





Leaf Cache

Cache module for Leaf.

leaf install cache

Or with composer:

composer require leafs/cache

Usage

You can use the cache module to store data, usually to avoid repeated expensive operations.

Cache data forever:

$value = cache(
    'key',
    function() {
        // expensive operation
        return 'value';
    },
);

Cache data for a specific time (in seconds):

$value = cache(
    'key',
    600, // 10 minutes
    function() {
        // expensive operation
        return 'value';
    },
);