PHPackages                             salehhashemi/laravel-configurable-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. salehhashemi/laravel-configurable-cache

ActiveLibrary[Caching](/categories/caching)

salehhashemi/laravel-configurable-cache
=======================================

Configurable Laravel cache manager

v1.4.0(2y ago)2114.5k↑150%2[1 PRs](https://github.com/salehhashemi1992/laravel-configurable-cache/pulls)1MITPHPPHP ^8.1

Since Oct 26Pushed 11mo ago4 watchersCompare

[ Source](https://github.com/salehhashemi1992/laravel-configurable-cache)[ Packagist](https://packagist.org/packages/salehhashemi/laravel-configurable-cache)[ Docs](https://github.com/salehhashemi1992/laravel-configurable-cache)[ RSS](/packages/salehhashemi-laravel-configurable-cache/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (5)Versions (7)Used By (1)

Laravel Configurable Cache
==========================

[](#laravel-configurable-cache)

[![Latest Version on Packagist](https://camo.githubusercontent.com/43333a152301e90879aeed2a8dc33e6883ad186e9c23d6acc12590f15ede3a1e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73616c656868617368656d692f6c61726176656c2d636f6e666967757261626c652d63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/salehhashemi/laravel-configurable-cache)[![Total Downloads](https://camo.githubusercontent.com/5ab142d776c746452a946eea6937cebcdedcab23f6dea8cc1a2e233a5639b4a0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73616c656868617368656d692f6c61726176656c2d636f6e666967757261626c652d63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/salehhashemi/laravel-configurable-cache)[![GitHub Actions](https://camo.githubusercontent.com/6d53fde8cd4c03370a5e674d6be20878e8349e0f5704d10bbad70b1114e0db22/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73616c656868617368656d69313939322f6c61726176656c2d636f6e666967757261626c652d63616368652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473)](https://github.com/salehhashemi1992/laravel-configurable-cache/actions/workflows/run-tests.yml)[![GitHub Actions](https://camo.githubusercontent.com/feeb0ffcc6a7ce5c3e2a18be8435385cd34fc99f8badeb96b21f1da26186f299/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73616c656868617368656d69313939322f6c61726176656c2d636f6e666967757261626c652d63616368652f7374617469632d616e616c797369732e796d6c3f6272616e63683d6d61696e266c6162656c3d7374617469632d616e616c79736973)](https://github.com/salehhashemi1992/laravel-configurable-cache/actions/workflows/static-analysis.yml)[![codecov](https://camo.githubusercontent.com/d6c7f7a08a98a881e1f44d270e2f580f680a0377614a4a4c5f72bde5548143ae/68747470733a2f2f636f6465636f762e696f2f67682f73616c656868617368656d69313939322f6c61726176656c2d636f6e666967757261626c652d63616368652f67726170682f62616467652e7376673f746f6b656e3d43414136533836525a49)](https://codecov.io/gh/salehhashemi1992/laravel-configurable-cache)[![PHPStan](https://camo.githubusercontent.com/f60d96f7c2579690ab6dfa8918f777fe93a02a92301c661eb38a85861a92b780/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230382d627269676874677265656e2e7376673f7374796c653d666c6174)](https://phpstan.org/)[![PHP Version Require](https://camo.githubusercontent.com/89dd756cae4c10b9344f59a50eaa8fd52320c20d069ba88e91dedc0bf70f22bc/687474703a2f2f706f7365722e707567782e6f72672f73616c656868617368656d692f6c61726176656c2d636f6e666967757261626c652d63616368652f726571756972652f706870)](https://packagist.org/packages/salehhashemi/laravel-configurable-cache)

[![Header Image](./assets/header.png)](./assets/header.png)

Features
--------

[](#features)

- Provides configurable cache settings with dedicated ttl and prefix for each
- Supports all main cache operations provided by Laravel, such as put, get, increment, and delete

Requirements
------------

[](#requirements)

- `PHP: ^8.1`
- `Laravel framework: ^9`

VersionL9L10L111.4✅✅✅Installation
------------

[](#installation)

You can install the package via composer:

```
composer require salehhashemi/laravel-configurable-cache
```

Next, from the command line type:

```
php artisan vendor:publish --provider="Salehhashemi\ConfigurableCache\ConfigurableCacheServiceProvider"
```

Finally, adjust the settings in the published configuration file located in `config/configurable-cache.php` as per your requirements.

Usage
-----

[](#usage)

To use the package, you can use the `ConfigurableCache` class methods. Here's an example:

```
use Salehhashemi\ConfigurableCache\ConfigurableCache;

// Storing an item in the cache with `_tiny_` prefix for 15 minutes
ConfigurableCache::put('testKey', 'Hello World!', 'tiny');

// Retrieving an item from the cache with `_short_` prefix that is stored for an hour
$value = ConfigurableCache::get('testKey', 'short');

// Delete a cache item with `_otp_` prefix
ConfigurableCache::delete('testKey', 'otp');

// if `testKey` doesn't exist in the 'default' cache, the Closure will be executed and its result will be stored in the cache under `testKey` with `_default_` prefix
$value = ConfigurableCache::remember('testKey', function () {
    return 'Hello World!';
});
```

Default configuration
---------------------

[](#default-configuration)

You can change these configurations in your configurable-cache.php config file:

```
'configs' => [
    'default' => [
        'prefix' => '_default_',
        'duration' => '+1 Year',
    ],
    'tiny' => [
        'prefix' => '_tiny_',
        'duration' => '+15 minutes',
    ],
    'short' => [
        'prefix' => '_short_',
        'duration' => '+1 hour',
    ],
    'otp' => [
        'prefix' => '_otp_',
        'duration' => '+3 minutes',
    ],
]

```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](changelog.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](contributing.md) for details.

Credits
-------

[](#credits)

- [Saleh Hashemi](https://github.com/salehhashemi1992)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](license.md) for more information.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance42

Moderate activity, may be stable

Popularity34

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 98.1% 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

Every ~142 days

Total

5

Last Release

730d ago

### Community

Maintainers

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

---

Top Contributors

[![salehhashemi1992](https://avatars.githubusercontent.com/u/81674631?v=4)](https://github.com/salehhashemi1992 "salehhashemi1992 (51 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")

---

Tags

cachecache-managerlaravellaravelcacheCacheManager

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/salehhashemi-laravel-configurable-cache/health.svg)

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

###  Alternatives

[swayok/alternative-laravel-cache

Replacements for Laravel's redis and file cache stores that properly implement tagging idea. Powered by cache pool implementations provided by http://www.php-cache.com/

202541.1k6](/packages/swayok-alternative-laravel-cache)[arifhp86/laravel-clear-expired-cache-file

Remove laravel expired cache file/folder

36128.7k](/packages/arifhp86-laravel-clear-expired-cache-file)[byerikas/cache-tags

Allows for Redis/Valkey cache flushing multiple tagged items by a single tag.

1413.9k](/packages/byerikas-cache-tags)

PHPackages © 2026

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