PHPackages                             bnomei/kirby3-redis-cachedriver - 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. bnomei/kirby3-redis-cachedriver

ActiveKirby-plugin[Caching](/categories/caching)

bnomei/kirby3-redis-cachedriver
===============================

Advanced Redis cache-driver with in-memory store, transactions and preloading

5.1.0(1y ago)101.7k↓33.3%[1 PRs](https://github.com/bnomei/kirby3-redis-cachedriver/pulls)MITPHPPHP &gt;=8.2CI passing

Since Dec 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/bnomei/kirby3-redis-cachedriver)[ Packagist](https://packagist.org/packages/bnomei/kirby3-redis-cachedriver)[ RSS](/packages/bnomei-kirby3-redis-cachedriver/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (34)Used By (0)

Advanced Kirby Redis Cache-Driver
=================================

[](#advanced-kirby-redis-cache-driver)

[![Kirby 5](https://camo.githubusercontent.com/b1a1b2ccd58e96259a9722c2489d91f40378c01b6c4c3e9fd27ed1d12c269d7c/68747470733a2f2f666c61742e62616467656e2e6e65742f62616467652f4b697262792f353f636f6c6f723d454343373438)](https://getkirby.com)[![PHP 8.2](https://camo.githubusercontent.com/fd050028b4459f3f6e4db5703412957375ceb180d27951213d421eb2a23c8c8e/68747470733a2f2f666c61742e62616467656e2e6e65742f62616467652f5048502f382e323f636f6c6f723d3445354239332669636f6e3d706870266c6162656c)](https://camo.githubusercontent.com/fd050028b4459f3f6e4db5703412957375ceb180d27951213d421eb2a23c8c8e/68747470733a2f2f666c61742e62616467656e2e6e65742f62616467652f5048502f382e323f636f6c6f723d3445354239332669636f6e3d706870266c6162656c)[![Release](https://camo.githubusercontent.com/f821f84daddef8bd9fc6222a89dcbe071fb5da56f588155148d2136f662e3edc/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f762f626e6f6d65692f6b69726279332d72656469732d63616368656472697665723f636f6c6f723d6165383166662669636f6e3d676974687562266c6162656c)](https://camo.githubusercontent.com/f821f84daddef8bd9fc6222a89dcbe071fb5da56f588155148d2136f662e3edc/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f762f626e6f6d65692f6b69726279332d72656469732d63616368656472697665723f636f6c6f723d6165383166662669636f6e3d676974687562266c6162656c)[![Downloads](https://camo.githubusercontent.com/4b9c26862fe99db7239908b117e90c06cf5d6eba4c33336893d2b5ad68cb474a/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f64742f626e6f6d65692f6b69726279332d72656469732d63616368656472697665723f636f6c6f723d3237323832322669636f6e3d676974687562266c6162656c)](https://camo.githubusercontent.com/4b9c26862fe99db7239908b117e90c06cf5d6eba4c33336893d2b5ad68cb474a/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f64742f626e6f6d65692f6b69726279332d72656469732d63616368656472697665723f636f6c6f723d3237323832322669636f6e3d676974687562266c6162656c)[![Coverage](https://camo.githubusercontent.com/dd2f2c6fb19549e62c38584220bf8ec7ea5b76e9a62102496a9ec93f09b160d1/68747470733a2f2f666c61742e62616467656e2e6e65742f636f6465636c696d6174652f636f7665726167652f626e6f6d65692f6b69726279332d72656469732d63616368656472697665723f69636f6e3d636f6465636c696d617465266c6162656c)](https://codeclimate.com/github/bnomei/kirby3-redis-cachedriver)[![Maintainability](https://camo.githubusercontent.com/f1f0dbd8d78cbccc062591c7f592128e8d760cb6558e84633f96622064b18554/68747470733a2f2f666c61742e62616467656e2e6e65742f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f626e6f6d65692f6b69726279332d72656469732d63616368656472697665723f69636f6e3d636f6465636c696d617465266c6162656c)](https://codeclimate.com/github/bnomei/kirby3-redis-cachedriver/issues)[![Discord](https://camo.githubusercontent.com/36eaef1b06f4996feb7587aa3281dcbd658e57535bc6b5e10110ed108e7a7a03/68747470733a2f2f666c61742e62616467656e2e6e65742f62616467652f646973636f72642f626e6f6d65693f636f6c6f723d3732383964612669636f6e3d646973636f7264266c6162656c)](https://discordapp.com/users/bnomei)[![Buymecoffee](https://camo.githubusercontent.com/62e55d1129b82bf9c2fd4656451e81ab87a9787e7c9676ca58276532ed9666ee/68747470733a2f2f666c61742e62616467656e2e6e65742f62616467652f69636f6e2f646f6e6174653f69636f6e3d6275796d6561636f6666656526636f6c6f723d464638313346266c6162656c)](https://www.buymeacoffee.com/bnomei)

Advanced Redis cache-driver for Kirby CMS with in-memory store, transactionsd and preloading

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

[](#installation)

- unzip [master.zip](https://github.com/bnomei/kirby3-redis-cachedriver/archive/master.zip) as folder `site/plugins/kirby3-redis-cachedriver` or
- `git submodule add https://github.com/bnomei/kirby3-redis-cachedriver.git site/plugins/kirby3-redis-cachedriver` or
- `composer require bnomei/kirby3-redis-cachedriver`

Why Redis?
----------

[](#why-redis)

[Memcached](https://github.com/memcached/memcached/wiki/ConfiguringServer#commandline-arguments) and [APCu](https://www.php.net/manual/en/apc.configuration.php) have more restrictive defaults. Redis does not have these limitations and is by very fast with [proper configuration](https://blog.opstree.com/2019/04/16/redis-best-practices-and-performance-tuning/).

Defaults forMemcachedAPCuRedismax memory size64MB32MB0 (none)size of key/value pair1MB4MB512MBTip

From my experience Memcached is very slow compared to APCu or Redis. Just do not use it.

Setup Cache
-----------

[](#setup-cache)

Set your Kirby [Cache-Driver](https://getkirby.com/docs/guide/cache#cache-drivers-and-options) to `adredis` for Plugin caches or in your `site/config/config.php`. All Redis-related params can be callbacks. You might even load values from an [.env File](https://github.com/bnomei/kirby3-dotenv).

**site/config/config.php**

```
return [
    'bnomei.turbo.cache.content' => [
        'type' => 'adredis',
        'host' => function() { return env('REDIS_HOST'); },
        'port' => function() { return env('REDIS_PORT'); },
        // 'database' => function() { return env('REDIS_DATABASE'); },
        // 'password' => function() { return env('REDIS_PASSWORD'); },
    ],
];
```

Note

Why `adredis`? Because Kirby v5 ships with a built-in cache-driver for redis aptly named `redis`. The one from this plugin add in-memory store, transactions and preloading.

### (optional) Setup Cache for Content Files

[](#optional-setup-cache-for-content-files)

Combine this plugin with [Kirby Turbo](https://github.com/bnomei/kirby-turbo) to set up a cache for content files.

### How to use Redis Cache Driver with Kirby or other plugins

[](#how-to-use-redis-cache-driver-with-kirby-or-other-plugins)

You must set the cache drivers for the desired cache (or sub-cache) to type of `adredis`, with additional options if needed.

**site/config/config.php**

```
