PHPackages                             dwi-wijonarko/laravel-simple-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. dwi-wijonarko/laravel-simple-cache

ActiveLibrary[Caching](/categories/caching)

dwi-wijonarko/laravel-simple-cache
==================================

Simple cache management for Laravel with tags, warming, and monitoring dashboard

1.0.0(5mo ago)00MITPHPPHP ^8.0|^8.1|^8.2

Since Dec 11Pushed 5mo agoCompare

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

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

Laravel Simple Cache Manager
============================

[](#laravel-simple-cache-manager)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e62452c140bfcfcb3edf2030aaeb98598bc6ace4db644dd0e810dd4497515328/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6477692d77696a6f6e61726b6f2f6c61726176656c2d73696d706c652d63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dwi-wijonarko/laravel-simple-cache)[![Total Downloads](https://camo.githubusercontent.com/69b64559c57950af2280b7fb73839ec4c77588958c2722ecaf3ab22ad4816f97/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6477692d77696a6f6e61726b6f2f6c61726176656c2d73696d706c652d63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dwi-wijonarko/laravel-simple-cache)

A simple and elegant cache management package for Laravel with tag support, cache warming, pattern-based clearing, and a beautiful monitoring dashboard.

Features
--------

[](#features)

- 🏷️ **Tag-based caching** - Organize and clear cache by tags
- 🔥 **Cache warming** - Pre-load cache with predefined data
- 🎯 **Pattern clearing** - Clear multiple cache keys using Redis patterns
- 📊 **Dashboard** - Beautiful web interface to monitor and manage cache
- 🛠️ **Artisan commands** - CLI tools for cache management
- 🔌 **Trait support** - Easy integration with Eloquent models
- 📝 **Helper functions** - Convenient global helpers
- 🚀 **Fluent API** - Chainable methods for clean code

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

[](#requirements)

- PHP 8.0 or higher
- Laravel 9.x, 10.x, or 11.x
- Redis (optional, for advanced features)

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require dwi-wijonarko/laravel-simple-cache
```

Publish the configuration file:

```
php artisan vendor:publish --tag=simple-cache-config
```

Optionally, publish the views:

```
php artisan vendor:publish --tag=simple-cache-views
```

Configuration
-------------

[](#configuration)

The configuration file `config/simple-cache.php` contains:

```
return [
    'default_ttl' => 3600, // Default cache TTL in seconds
    'auto_clear_on_save' => true, // Auto clear cache on model save
    'auto_clear_on_delete' => true, // Auto clear cache on model delete
    'dashboard_enabled' => true, // Enable/disable dashboard
    'dashboard_route' => 'cache-dashboard', // Dashboard route
    'dashboard_middleware' => ['web', 'auth'], // Dashboard middleware
    'warmers' => [], // Cache warmers configuration
];
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use DwiWijonarko\SimpleCache\Facades\CacheManager;

// Store cache
CacheManager::put('key', 'value', 3600);

// Retrieve cache
$value = CacheManager::get('key');

// Remember cache
$users = CacheManager::remember('users', function () {
    return User::all();
}, 3600);

// Forget cache
CacheManager::forget('key');
```

### Tagged Cache

[](#tagged-cache)

```
// Store with tags
CacheManager::tags(['users', 'active'])
    ->put('active_users', $users, 3600);

// Retrieve with tags
$users = CacheManager::tags(['users', 'active'])
    ->get('active_users');

// Clear by tags
CacheManager::tags(['users'])->flush();
```

### Cache Warming

[](#cache-warming)

Define warmers in `config/simple-cache.php`:

```
'warmers' => [
    'homepage:stats' => [
        'callback' => fn() => [
            'users' => User::count(),
            'posts' => Post::count(),
        ],
        'tags' => ['homepage', 'stats'],
        'ttl' => 3600,
    ],
],
```

Warm cache via command:

```
php artisan cache:warm
php artisan cache:warm --force
```

### Pattern-based Clearing (Redis only)

[](#pattern-based-clearing-redis-only)

```
// Clear all user cache keys
CacheManager::clearByPattern('users:*');
```

### Model Integration

[](#model-integration)

Use the `Cacheable` trait in your models:

```
use DwiWijonarko\SimpleCache\Traits\Cacheable;

class User extends Model
{
    use Cacheable;

    protected $cachePrefix = 'user';
    protected $cacheTags = ['users'];
    protected $cacheTtl = 3600;
}

// Usage
$users = User::cached();
$user->cacheModel();
$user->clearCache();
```

### Helper Functions

[](#helper-functions)

```
// Get cache manager instance
$cache = simple_cache();

// Tagged cache helper
cache_tags(['users', 'active'])->put('key', 'value');
```

Artisan Commands
----------------

[](#artisan-commands)

```
# Display cache statistics
php artisan cache:stats

# Clear cache by tag
php artisan cache:clear-tag users posts

# Warm cache
php artisan cache:warm
php artisan cache:warm --force
```

Dashboard
---------

[](#dashboard)

Access the cache dashboard at: `http://your-app.test/cache-dashboard`

The dashboard provides:

- Real-time cache statistics
- Clear cache by tag
- Clear cache by pattern (Redis)
- Warm cache button

Configure dashboard access in `config/simple-cache.php`:

```
'dashboard_enabled' => true,
'dashboard_route' => 'cache-dashboard',
'dashboard_middleware' => ['web', 'auth'],
```

API Reference
-------------

[](#api-reference)

### CacheManager Methods

[](#cachemanager-methods)

```
// Chainable configuration
->tags(array|string $tags)
->ttl(int $seconds)
->store(string $store)

// Cache operations
->remember(string $key, Closure $callback, int $ttl = null)
->rememberForever(string $key, Closure $callback)
->put(string $key, $value, int $ttl = null)
->get(string $key, $default = null)
->has(string $key)
->forget(string $key)
->flush()

// Advanced operations
->clearByPattern(string $pattern)
->warm(array $warmers)
->stats()
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Dwi Wijonarko](https://github.com/dwi-wijonarko)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

Support
-------

[](#support)

For support, please open an issue on [GitHub](https://github.com/dwi-wijonarko/laravel-simple-cache/issues).

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance73

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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

153d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/80eced302aeb4d8910ebcb22393a40e73dffe3a87a8d6a6133bae47b6b571c18?d=identicon)[dwi-wijonarko](/maintainers/dwi-wijonarko)

---

Top Contributors

[![dwi-wijonarko](https://avatars.githubusercontent.com/u/106038112?v=4)](https://github.com/dwi-wijonarko "dwi-wijonarko (1 commits)")

---

Tags

laravelrediscachetagscache warmingcache manager

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dwi-wijonarko-laravel-simple-cache/health.svg)

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

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.2M51](/packages/spatie-laravel-responsecache)[awssat/laravel-visits

Laravel Redis visits counter for Eloquent models

975163.6k2](/packages/awssat-laravel-visits)[nexxai/laravel-cfcache

A handful of Cloudflare cache helpers for Laravel

1317.7k](/packages/nexxai-laravel-cfcache)[byerikas/cache-tags

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

1413.9k](/packages/byerikas-cache-tags)[michele-angioni/support

Support is a Laravel package which promotes the use of best practices and design patterns.

181.4k1](/packages/michele-angioni-support)

PHPackages © 2026

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