PHPackages                             handmadeweb/statamic-multi-cacher - 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. handmadeweb/statamic-multi-cacher

ActiveLibrary

handmadeweb/statamic-multi-cacher
=================================

10[1 issues](https://github.com/HandmadeWeb/statamic-multi-cacher/issues)PHP

Since Jul 27Pushed 4y ago1 watchersCompare

[ Source](https://github.com/HandmadeWeb/statamic-multi-cacher)[ Packagist](https://packagist.org/packages/handmadeweb/statamic-multi-cacher)[ RSS](/packages/handmadeweb-statamic-multi-cacher/feed)WikiDiscussions main Synced 4w ago

READMEChangelogDependenciesVersions (3)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4392531699b50afdada3766e9d323375c84ecc86ff930f6a984ef98439693420/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68616e646d6164657765622f73746174616d69632d6d756c74692d6361636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/handmadeweb/statamic-multi-cacher)[![Total Downloads](https://camo.githubusercontent.com/e0f2d87187af127ef4ad7cc244ddc5017aab60a46d6ff558dd3436f8ecbf344d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68616e646d6164657765622f73746174616d69632d6d756c74692d6361636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/handmadeweb/statamic-multi-cacher)[![MIT Licensed](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Run Tests](https://github.com/handmadeweb/statamic-multi-cacher/actions/workflows/tests.yml/badge.svg)](https://github.com/handmadeweb/statamic-multi-cacher/actions/workflows/tests.yml)[![Statamic v3.1](https://camo.githubusercontent.com/ac0c9dd27015cf730c47da34e36560870c9f7fb1c01bc3c4d8c2f56127bc1e99/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53746174616d69632d332e312b2d4646323639453f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/ac0c9dd27015cf730c47da34e36560870c9f7fb1c01bc3c4d8c2f56127bc1e99/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53746174616d69632d332e312b2d4646323639453f7374796c653d666c61742d737175617265)

Statamic Multi Cacher is a caching strategy "redirector" of sorts, it can be used to provide different caching strategies based on your own logic.

An example of this could be to bypass/disable the cache for super admins and serve the `half` strategy to everyone else.

THIS IS A BETA
--------------

[](#this-is-a-beta)

Please be aware that it is not recommended to use this in production just yet.

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

[](#requirements)

- Statamic 3.1 or higher

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

[](#installation)

You can install the package via composer:

```
composer require handmadeweb/statamic-multi-cacher
```

Usage
-----

[](#usage)

First add the strategy to your `static_cache` config

```
'strategies' => [

    'half' => [
        'driver' => 'application',
        'expiry' => null,
    ],

    'full' => [
        'driver' => 'file',
        'path' => public_path('static'),
        'lock_hold_length' => 0,
    ],

    'multi' => [
        'driver' => 'multi-cacher',
    ],
],
```

Then specify the name of the strategies that you want to be available to the `multi-cacher`

```
'multi' => [
    'driver' => 'multi-cacher',
    'strategies' => [
        'half',
        'full',
    ],
],
```

Then update the `static_cache` strategy at the top of the configuration to:

```
'strategy' => 'multi',
```

It is important to note, that if strategies are omitted or are empty, then the `multi-cacher` strategy will default to `null`. The `null` strategy will always be available for selection, so you don't need to add it to your strategies section.

If you don't override the `CacheSelector` which is `\HandmadeWeb\StatamicMultiCacher\CacheSelector` then the first strategy will always be used, In the above example this would be `half`.

Overriding can be done by extending the `CacheSelector` class like so:

```
