Custom cache in plugin?

How do I use a custom cache in a plugin?

This is my plugin code:

<?php

Kirby::plugin('bvdputte/test', [
    'options' => [
        'cache' => true
    ]
]);

$test = $kirby->cache("bvdputte.test");
$test->set("foo", "bar");
var_dump($test);

var_dump($test->get("foo"));

I’m seeing an empty Kirby\Cache\cache object and a null as return value for the getter.

What am I doing wrong?

The named instance works for me, haven’t tried your version:

'options' [
    'cache.api' => true,
]
$cache = $kirby->cache('moeli.plugin.api');

that should work. maybe a bug/change introduced in 3.0.1?
https://getkirby.com/docs/guide/cache#plugin-caches

Can anyone get this to work?

Code below is a very small plugin, which can be put in e.g. site/plugins/test/index.php to test.

<?php

Kirby::plugin('superwoman/superplugin', [
    'options' => [
        'cache' => true
    ]
]);

$test = $kirby->cache("superwoman.superplugin");
var_dump($test);

$test->set("foo", "bar");
var_dump($test);
var_dump($test->get("foo"));

This is basically the example from the docs. I’ve tried this in a clean starterkit (3.0.1) to no avail.

Edit: FYI I just tried this in starterkit 3.0, with same result…

Thx :raised_hands:. I just wanted to be sure more before filing a bug.