getkirby / ideas

This is the backlog of ideas and feature requests from the last two years. Use our new feedback platform to post your new ideas or vote on existing ideas.
https://feedback.getkirby.com
20 stars 0 forks source link

Cache: support global cache setting #199

Open bnomei opened 5 years ago

bnomei commented 5 years ago

Describe the bug plugin cache is file cache unless plugin developer sets it up differently https://github.com/getkirby/kirby/blob/feb17027d22a97249f50663365343b159d4302fe/src/Cms/AppCaches.php#L65

To Reproduce use any plugin and set cache to memcached. plugin will still use file cache.

Expected behavior i expected plugins to have same setting as pages cache by default. otherwise people installing plugins would have to know about this problem and set the cache properties for every plugin and all of their non custom and custom named caches again.

config.php

return [
    'cache' => [
        'driver' => 'memcached'
    ],

    'bnomei.autoid.cache' => [ // will this work? as far as i can tell it does not.
        'active' => true,
        'type' => 'memcached'
    ],
    'bnomei.autoid.cache.xzy' => [ // example custom cache will this work? not as well.
        'active' => true,
        'type' => 'memcached'
    ],
// ...
];

Kirby Version 3.0.1

Alternative suggestion but less obvious for developers make the type an optional callback. so plugin developers could at least do

plugin index.php

Kirby::plugin('bnomei/autoid', [
'options' => [ 
  'cache' => [
    'active' => true,
    'type' => function() { return kirby()->option('cache.type'); },
    // 'type' => kirby()->option('cache.driver'), // or does this work?
  ],
//...

In forum https://forum.getkirby.com/t/php7-2-memcached-not-memcache-in-plugins/12822/2

bnomei commented 5 years ago

related: what if a plugin set cache to memcached but its not available? will it silently fallback to filebased cache?

bastianallgeier commented 5 years ago

This is not a bug, but more a suggestion. We don't have a global cache type setup so far. There's only cache.pages.type and I don't think that all other cache setups should inherit this by default. But I agree that it's a good idea to introduce a global type.

bnomei commented 5 years ago

since the setting is called cache.driver i sortof expected it to be global. but i am glad to hear this issue will be taken care of one way or another.

what about my question about the fallback? if anplugin sets memcached but it is not available will it fallback to file cache?