PHPackages                             temperworks/laravel-russian-doll-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. [Templating &amp; Views](/categories/templating)
4. /
5. temperworks/laravel-russian-doll-cache

ActiveLibrary[Templating &amp; Views](/categories/templating)

temperworks/laravel-russian-doll-cache
======================================

Laravel Russian Doll Cache Blade Directive

0.1(8y ago)695.7k1MITPHPPHP &gt;=5.5.0

Since Jul 13Pushed 6y ago3 watchersCompare

[ Source](https://github.com/TemperWorks/laravel-russian-doll-cache)[ Packagist](https://packagist.org/packages/temperworks/laravel-russian-doll-cache)[ Docs](https://github.com/temperworks/laravel-russian-doll-cache)[ RSS](/packages/temperworks-laravel-russian-doll-cache/feed)WikiDiscussions master Synced 4w ago

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

Laravel Russian Doll Cache Blade Directive
==========================================

[](#laravel-russian-doll-cache-blade-directive)

Intro
-----

[](#intro)

This package provides a Blade directive to cache rendered partials in Laravel, based on the LRU auto evict policy of memcached (by default) or redis [(optional)](https://redis.io/topics/lru-cache)

In this implementation you don't need to explicitly set cache keys. The cache key will be automatically generated based on the data you pass to the partial.

If the data implements `getCacheKey` (by including the Cacheable trait) the key is based on the class, id and updated\_at timestamp of the object. When the object changes, the key updates and the view will be regenerated on the next visit.

If the data does not implement `getCacheKey`, an md5 hash is used as cache key.

The cache store will be responsible for auto evicting the less recently used keys when the store is full.

Install
-------

[](#install)

**Make sure your cache store has `max_memory` configured and a proper eviction policy is set.**

You can install the package via Composer:

```
$ composer require temperworks/laravel-russian-doll-cache
```

Start by registering the package's service provider and facade:

```
// config/app.php

'providers' => [
  ...
  TemperWorks\RussianDollCache\RussianDollCacheServiceProvider::class,
],
```

Usage
-----

[](#usage)

The package registers a blade directive, `@cache`. The cache directive accepts the same arguments as `@include`, plus optional parameters for the amount of minutes a view should be cached for. If no minutes are provided, the view will be remembered untill it gets deleted by the cache store.

Only the data you pass explicitly to the partial will be available within. Unlike the behavior of `@include`, global variables will be ignored to make sure all the variables will be represented in the cache key.

```
{{-- Simple example --}}
@cache('footer.section.partial')

{{-- With extra view data --}}
@cache('products.card', ['product' => $category->products->first()])

{{-- For a certain time --}}
{{-- (cache will invalidate in 60 minutes in this example, set null to remember forever) --}}
@cache('homepage.news', null, 60)

```

### Clearing The PartialCache

[](#clearing-the-partialcache)

Since we rely on the cache store to automatically flush old data, it's not needed to manually remove keys.

If you want to flush all entries, you'll need to either call `PartialCache::flush()` (note: this is only supported by drivers that support tags), or clear your entire cache.

### Configuration

[](#configuration)

Configuration isn't necessary, but there are some options specified in the config file:

- `russian-doll-cache.enabled`: Fully enable or disable the cache. Defaults to `true`.
- `russian-doll-cache.directive`: The name of the blade directive to register. Defaults to `cache`.
- `russian-doll-cache.key`: The base key that used for cache entries. Defaults to `partialcache`.

Credits
-------

[](#credits)

This package is forked from on [spatie-partialcache](https://github.com/spatie/laravel-partialcache) by the awesome webdesign agency [Spatie](https://spatie.be/opensource).

- [Jeroen Jochems](http://temper.works)
- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

3274d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/107550932?v=4)[Reda BIYA](/maintainers/rbiya)[@rbiya](https://github.com/rbiya)

![](https://www.gravatar.com/avatar/68c2477623a4630f1455898d4bc02ec31b12e5fb572e949648aebae5c17986f3?d=identicon)[backend-temper](/maintainers/backend-temper)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (15 commits)")[![JeroenJochems](https://avatars.githubusercontent.com/u/1180505?v=4)](https://github.com/JeroenJochems "JeroenJochems (13 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (12 commits)")[![billmn](https://avatars.githubusercontent.com/u/779534?v=4)](https://github.com/billmn "billmn (1 commits)")[![m1guelpf](https://avatars.githubusercontent.com/u/23558090?v=4)](https://github.com/m1guelpf "m1guelpf (1 commits)")

---

Tags

cachinglaravelredislaravelbladecacherussiandolltemper

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/temperworks-laravel-russian-doll-cache/health.svg)

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

###  Alternatives

[radic/blade-extensions

Laravel package providing additional Blade extensions: foreach (with $loop data like twig), break, continue, set,array (multiline), etc

264322.7k5](/packages/radic-blade-extensions)[angus-mcritchie/blade-boost-directive

Lightning-Fast Blade Components with `@boost` Directive

3913.1k](/packages/angus-mcritchie-blade-boost-directive)

PHPackages © 2026

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