mirror of
https://github.com/yiisoft/yii2.git
synced 2026-03-09 16:57:53 +01:00
* Cache user assignments to avoid unnecessary DB queries alternative to #9138 and #10981, only cache on `checkAccess` call which is usually called on every request. Cache is not necessary in RBAC management. Similar to #14061 but includes proper cache invalidation and test. `getAssignments()` always queries the DB. The cache is only applied on `checkAccess` calls, and invalidated as soon as the RBAC structure is modified through the manager component (verified by the test case). Regarding [concerns of memory usage](https://github.com/yiisoft/yii2/pull/14061#issuecomment-297982502) if used in batch mode on multiple users, you can call `invalidateCache()` method if this really causes a problem. fixes #7743 close #9138 close #14061 close #10981 See also - https://github.com/yiisoft/yii2/issues/7626#issuecomment-77745166 - https://github.com/yiisoft/yii2/pull/14061#issuecomment-319645488 * improve test naming * fix tests * fix assignment cache for non-scalar user-ids
24 lines
487 B
PHP
24 lines
487 B
PHP
<?php
|
|
|
|
namespace yiiunit\framework\log;
|
|
|
|
use yii\base\Exception;
|
|
use yii\log\Target;
|
|
|
|
/**
|
|
* ArrayTarget logs messages into an array, useful for tracking data in tests.
|
|
*/
|
|
class ArrayTarget extends Target
|
|
{
|
|
public $exportInterval = 1000000;
|
|
|
|
/**
|
|
* Exports log [[messages]] to a specific destination.
|
|
*/
|
|
public function export()
|
|
{
|
|
// throw exception if message limit is reached
|
|
throw new Exception('More than 1000000 messages logged.');
|
|
}
|
|
}
|