Closed bscheshirwork closed 1 year ago
So... This will be called in https://github.com/yiisoft/yii2-debug/blob/b37f414959c2fafefb332020b42037cd17c1cb7f/panels/UserPanel.php#L238
same situation: I can't see any cache calling
Yes. Worth fixing.
we can use db cache
/**
* @inheritdoc
* The roles returned by this method include the roles assigned via [[$defaultRoles]].
*/
public function getRolesByUser($userId)
{
if ($this->isEmptyUserId($userId)) {
return [];
}
$query = (new Query())->select('b.*')
->from(['a' => $this->assignmentTable, 'b' => $this->itemTable])
->where('{{a}}.[[item_name]]={{b}}.[[name]]')
->andWhere(['a.user_id' => (string) $userId])
->andWhere(['b.type' => Item::TYPE_ROLE]);
$roles = $this->getDefaultRoleInstances();
$rows = $this->db->cache(function () use ($query) {
return $query->createCommand($this->db)->queryAll();
});
foreach ($rows as $row) {
$roles[$row['name']] = $this->populateItem($row);
}
return $roles;
}
but this is not correct - we must use only internal cache settings
Also we can use separate keys on main data (current) and other query data
https://github.com/yiisoft/yii2/blob/339f12969b264b4deae3ad0e88423162676348e1/framework/rbac/DbManager.php#L461-L483
What steps will reproduce the problem?
add
to config of rbac
check mysql query log
What is the expected result?
all of queries to db is stored to cache
What do you get instead?
each time
Additional info