Closed hofrob closed 6 years ago
Same could be said about rbac DbManager. There is no possibility to clear cache only for texts categories.
Now that I think about it.
In yii\rbac\DbManager you could just use the same cache with a different config:
https://github.com/yiisoft/yii2/blob/master/framework/rbac/DbManager.php#L64
The cache property accepts an array as config for the cache.
And in yii\web\UrlManager you can use a dedicated cache application component. Still confusing that there are two different approaches to the same problem.
And in yii\web\UrlManager you can use a dedicated cache application component. Still confusing that there are two different approaches to the same problem.
This actually should be fixed - Instance::ensure()
should be consistently used in such cases.
We could also make $cacheKey
public, so cache could be revalidated by changing this value. But this will break BC, so probably not an option in 2.0.
There are few places where such behavior is implemented. Maybe some common trait would be a good solution.
I'm not sure if it is related to this issue: i would like to set a cache dependency for the UrlManager cache in https://github.com/yiisoft/yii2/blob/master/framework/web/UrlManager.php#L278, both duration and dependency are always the default null - or should i open a new issue?
In my scenario I have an url rule like this:
<?php
namespace app\rules;
class SlugUrlRule extends \yii\web\UrlRule
{
public $modelClass;
public $attribute = 'slug';
public $paramName = 'slug';
public function init()
{
$slugs = array_filter($this->modelClass::find()->select($this->attribute)->column());
$this->pattern = '<'.$this->paramName.':(' . implode('|', $slugs) . ')>';
parent::init();
}
}
About original issue. You can specify separate cache instance there:
So I don't see a problem with flushing this separate instance.
@mahkali what for?
@samdark flushing the cache on change would indeed be more efficient as we don't require to check a dependency on every request.
What steps will reproduce the problem?
What is the expected result?
Additional info
https://github.com/yiisoft/yii2/blob/master/framework/web/UrlManager.php#L278