[已解决] Zizaco/Entrust 更新用户角色,角色权限时缓存不更新
版本信息
- Laravel 5.3
- zizaco/entrust: 5.2.x-dev 或 1.8.* ,两个版本都测试过
- 缓存驱动redis,memcached不行,array可行
更新用户组
$user->roles()->sync($roleList);
更新角色权限
$role->perms()->sync($permissions);
有遇到同样问题的吗?还是我哪里没搞对
我的解决办法
$user->roles()->sync($roleList);
if (Cache::getStore() instanceof TaggableStore) {
Cache::tags(Config::get('entrust.role_user_table'))->flush();
}
$role->perms()->sync($permissions);
if(Cache::getStore() instanceof TaggableStore) {
Cache::tags(Config::get('entrust.permission_role_table'))->flush();
}