PHPackages                             nodes/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. nodes/cache

AbandonedArchivedLibrary[Caching](/categories/caching)

nodes/cache
===========

Makes it easier to control and manage Laravel caching

1.0.11(6y ago)713.6k4PHP

Since Jan 23Pushed 6y ago1 watchersCompare

[ Source](https://github.com/nodes-php/nodes-php-cache)[ Packagist](https://packagist.org/packages/nodes/cache)[ RSS](/packages/nodes-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (30)Used By (0)

Cache
-----

[](#cache)

An easy integration for handling caching - in a structured way - for [Laravel](http://laravel.com/docs).

Cache keys often build up and ends up being 3+ params attenpended in a string. Or caching on urls will make different order of query params have different version of same cache. Query params are often handled as hashmaps or dictionaries, which does not have a locked order

The worst part is, you end up with having cache settings shattered all over your project.

This package will make your life much easier

[![Total downloads](https://camo.githubusercontent.com/fcc56cddf629fd295704cb404aecb9f83bc289d9d267bd95d63a2bca107f629e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e6f6465732f63616368652e737667)](https://packagist.org/packages/nodes/cache)[![Monthly downloads](https://camo.githubusercontent.com/cae56734ad25cdfe1e7f0540883a7286ef93ace63ca6526d5b8ce0cff770e6c7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6e6f6465732f63616368652e737667)](https://packagist.org/packages/nodes/cache)[![Latest release](https://camo.githubusercontent.com/fc17c7fbfc61e7ffeba805e9a5308f4f7dde7b62fe513d03c30a6f594894c8f8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6f6465732f63616368652e737667)](https://packagist.org/packages/nodes/cache)[![Open issues](https://camo.githubusercontent.com/ac440b557e275519b5ebb141ef7b557057867898d9ca83f20f94ddae92aeb815/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6e6f6465732d7068702f63616368652e737667)](https://github.com/nodes-php/cache/issues)[![License](https://camo.githubusercontent.com/564d7d2803d5e7027e72b11f5d29c8ea5570ee5031dfab31e8289a3724264932/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e6f6465732f63616368652e737667)](https://packagist.org/packages/nodes/cache)[![Star repository on GitHub](https://camo.githubusercontent.com/8f10f067fae60199b962211ebe3e080edce01d2de4fdf41812a7d856c032d347/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6e6f6465732d7068702f63616368652e7376673f7374796c653d736f6369616c266c6162656c3d53746172)](https://github.com/nodes-php/cache/stargazers)[![Watch repository on GitHub](https://camo.githubusercontent.com/0e9fbeaef6c4d8f3b54c4bb4130b8fcf51ebc69f2bf2b60131b865ecac5aabc2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f77617463686572732f6e6f6465732d7068702f63616368652e7376673f7374796c653d736f6369616c266c6162656c3d5761746368)](https://github.com/nodes-php/cache/watchers)[![Fork repository on GitHub](https://camo.githubusercontent.com/8e5a9b6d63f11076044235b01fc537efd15fa4ea5615466951212880754c8f74/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6e6f6465732d7068702f63616368652e7376673f7374796c653d736f6369616c266c6162656c3d466f726b)](https://github.com/nodes-php/cache/network)[![StyleCI](https://camo.githubusercontent.com/a7251f246de6d4b90888da195e81ca3f893697297b3def20bfb88ab0a9741b3c/68747470733a2f2f7374796c6563692e696f2f7265706f732f34353738363037302f736869656c64)](https://styleci.io/repos/45786070)

📝 Introduction
--------------

[](#-introduction)

One thing we at [Nodes](http://nodesagency.com) have been missing a lot in [Laravel](http://laravel.com/docs) is more structure of managing caches.

We've come up with a more flexible and structured way of managing caches and their lifetime. Also we've created a few helper methods to make it all a bit easier and awesome.

📦 Installation
--------------

[](#-installation)

To install this package you will need:

- Laravel 5.1+
- PHP 5.5.9+

You must then modify your `composer.json` file and run `composer update` to include the latest version of the package in your project.

```
"require": {
    "nodes/cache": "^1.0"
}
```

Or you can run the composer require command from your terminal.

```
composer require nodes/cache:^1.0
```

🔧 Setup
-------

[](#-setup)

Setup service provider in `config/app.php`

```
Nodes\Cache\ServiceProvider::class
```

Setup alias in `config/app.php`

```
'NodesCache' => Nodes\Cache\Support\Facades\Cache::class
```

Publish config file

```
php artisan vendor:publish --provider="Nodes\Cache\ServiceProvider"
```

If you want to overwrite any existing config files use the `--force` parameter

```
php artisan vendor:publish --provider="Nodes\Cache\ServiceProvider" --force
```

⚙ Usage
-------

[](#-usage)

### Global methods

[](#global-methods)

```
function cache_remember($cacheGroupKey, array $params = [], $data, $tags = null, \Closure $closure = null)
```

```
function cache_put($cacheGroupKey, array $params = [], $data, $tags = null)
```

```
function cache_get($cacheGroupKey, array $params = [], $tags = null)
```

```
function cache_forget($cacheGroupKey, array $params = [], $tags = null)
```

```
function cache_flush($tags)
```

```
function cache_wipe()
```

### Facade methods

[](#facade-methods)

```
\NodesCache::remember($cacheGroupKey, array $params = [], $data, $tags = null, \Closure $closure = null)
```

```
\NodesCache::put($cacheGroupKey, array $params = [], $data, $tags = null)
```

```
\NodesCache::get($cacheGroupKey, array $params = [], $tags = null)
```

```
\NodesCache::forget($cacheGroupKey, array $params = [], $tags = null)
```

```
\NodesCache::flush($tags)
```

```
\NodesCache::wipe()
```

Examples
--------

[](#examples)

First important thing is to create the config for you new cache group, config should be in /config/nodes/cache.php (else you forgot to vendor:publish)

```
'groups'   => [
/*
|--------------------------------------------------------------------------
| Project
|--------------------------------------------------------------------------
|
| Cache settings used by your project.
|
*/
'geographic' => [
    'continent.bySlug' => [
	'active'   => true,
	'key'      => 'geographic-continent-by-slug',
	'lifetime' => 3600,
    ],
...

```

Will give you a $cacheGroup `geographic.continent.bySlug`Remember to make the key unique to avoid conflicts

### Remember

[](#remember)

Remember is a way to both get and put to cache, 95% of cases this will be the right choice

```
return cache_remember('geographic.continent.bySlug', ['slug' => $slug], $tags, function () use ($slug) {

	// Look up in db
	$continent = $this->where('slug', $slug)->first();

	if (!$continent) {
		throw new EntityNotFoundException(sprintf('Could not find continent with slug [%s]', $slug));
	}

	return $continent;
});

```

This way we start by looking in cache, if data if found it will be returned. Else the closure will run where we look up the data in db and return. Returning it in closure will then cache it and return it.

### Put

[](#put)

Just put data in cache

```
// Look up in db
$continent = $this->where('slug', $slug)->first();
if (!$continent) {
	throw new EntityNotFoundException(sprintf('Could not find continent with slug [%s]', $slug));
}

// Put in cache
$success = cache_put('geographic.continent.bySlug', ['slug' => $slug], $continent)

```

`$success` is a bool

### Get

[](#get)

Just get data from cache

```
// Get from cache
$continent cache_get('geographic.continent.bySlug', ['slug' => $slug])

```

`$continent` is the continent or null

🏆 Credits
---------

[](#-credits)

This package is developed and maintained by the PHP team at [Nodes](http://nodesagency.com)

[![Follow Nodes PHP on Twitter](https://camo.githubusercontent.com/a898a5b14227bafa0c17c43be4f67460fe2b1dc3b88627d7b959e7fae4256a45/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f6e6f6465737068702e7376673f7374796c653d736f6369616c)](https://twitter.com/nodesphp) [![Tweet Nodes PHP](https://camo.githubusercontent.com/8c1a307180498b3bb360cf73e63da1bfa3afc0306f601be021acd1e85d2bb4e4/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f75726c2f687474702f6e6f6465737068702e7376673f7374796c653d736f6369616c)](https://twitter.com/nodesphp)

📄 License
---------

[](#-license)

This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 79.6% 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 ~64 days

Recently: every ~224 days

Total

24

Last Release

2277d ago

Major Versions

0.1.11 → 1.0.02016-05-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/3aaee2c2b7632254faa8a589817712bdab2c7d46778fb26994eef75b20ec9c08?d=identicon)[nodes](/maintainers/nodes)

---

Top Contributors

[![Casperhr](https://avatars.githubusercontent.com/u/1279756?v=4)](https://github.com/Casperhr "Casperhr (39 commits)")[![carmenioanamihaila](https://avatars.githubusercontent.com/u/20821982?v=4)](https://github.com/carmenioanamihaila "carmenioanamihaila (3 commits)")[![rugaard](https://avatars.githubusercontent.com/u/179868?v=4)](https://github.com/rugaard "rugaard (3 commits)")[![Zeneo](https://avatars.githubusercontent.com/u/5598307?v=4)](https://github.com/Zeneo "Zeneo (2 commits)")[![rasmusebbesen](https://avatars.githubusercontent.com/u/944158?v=4)](https://github.com/rasmusebbesen "rasmusebbesen (1 commits)")[![Saad-Amjad](https://avatars.githubusercontent.com/u/22954041?v=4)](https://github.com/Saad-Amjad "Saad-Amjad (1 commits)")

---

Tags

laravelcachenodes

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/nodes-cache/health.svg)](https://phpackages.com/packages/nodes-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)[salehhashemi/laravel-configurable-cache

Configurable Laravel cache manager

2114.5k1](/packages/salehhashemi-laravel-configurable-cache)

PHPackages © 2026

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