PHPackages                             leafs/cache - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. leafs/cache

ActiveLibrary[Caching](/categories/caching)

leafs/cache
===========

Leaf PHP cache module

v0.1.0(11mo ago)1178MITPHP

Since Sep 6Pushed 11mo agoCompare

[ Source](https://github.com/leafsphp/cache)[ Packagist](https://packagist.org/packages/leafs/cache)[ Docs](https://leafphp.dev/docs/utils/cache)[ GitHub Sponsors](https://github.com/leafsphp)[ Fund](https://opencollective.com/leaf)[ RSS](/packages/leafs-cache/feed)WikiDiscussions main Synced 4w ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

 [![](https://camo.githubusercontent.com/d98ee5e32c2ff016fdfdac6c42654a908f4cc34b229c7b00caacc5a717455ae8/68747470733a2f2f6c6561667068702e6465762f6c6f676f2d636972636c652e706e67)](https://camo.githubusercontent.com/d98ee5e32c2ff016fdfdac6c42654a908f4cc34b229c7b00caacc5a717455ae8/68747470733a2f2f6c6561667068702e6465762f6c6f676f2d636972636c652e706e67)

Leaf Cache
==========

[](#leaf-cache)

Cache module for Leaf.

```
leaf install cache
```

Or with composer:

```
composer require leafs/cache
```

Usage
-----

[](#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';
    },
);
```

Unlike other frameworks, the cache function will always return the cached value if it exists, meaning that the closure will only be executed if the cache key does not exist. So you don't need to check if the value exists before calling the cache function.

Extended Usage
--------------

[](#extended-usage)

The cache module is built on top of the Illuminate Cache component, so you can use all the features of that component. To do that, you can call the `cache()` function without any parameters to get the cache repository instance:

```
cache()->put('key', 'value', 600); // cache for 10 minutes
$value = cache()->get('key');
```

For most use cases, the `cache()` function is sufficient, but if you need more control, you can use the cache repository instance directly.

You can use this to manually overwrite a cache key:

```
// will not set the cache if it already exists
cache('key', 600, 'new value'); // cache for 10 minutes

// will always set the cache, even if it already exists
cache()->put('key', 'new value', 600); // cache for 10 minutes
```

###  Health Score

26

—

LowBetter than 40% of packages

Maintenance52

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

336d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/29547806?v=4)[Mychi](/maintainers/Mychi)[@mychi](https://github.com/mychi)

---

Top Contributors

[![mychidarko](https://avatars.githubusercontent.com/u/26604242?v=4)](https://github.com/mychidarko "mychidarko (4 commits)")

---

Tags

cacheleafPHP

### Embed Badge

![Health badge](/badges/leafs-cache/health.svg)

```
[![Health](https://phpackages.com/badges/leafs-cache/health.svg)](https://phpackages.com/packages/leafs-cache)
```

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.3M72](/packages/spatie-laravel-responsecache)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k161.4k1](/packages/mike-bronner-laravel-model-caching)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.9M106](/packages/mongodb-laravel-mongodb)[propaganistas/laravel-disposable-email

Disposable email validator

6023.2M7](/packages/propaganistas-laravel-disposable-email)[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21114.2k](/packages/iazaran-smart-cache)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

46273.9k](/packages/harris21-laravel-fuse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
