当用户已登录时,安全性组件会在每次请求时不断从用户提供程序重新加载数据。有没有办法避免这种情况?当您的用户提供程序不在本地数据库中时(例如,在 Web 服务中),这可能会大大减慢系统速度。
在每个请求中,我都会得到这个:
[2012-08-15 20:07:30] security.DEBUG: Read SecurityContext from the session [] []
[2012-08-15 20:07:30] security.DEBUG: Reloading user from user provider. [] []
你可以根据需要
决定是否刷新每个请求的用户,方法是重写给定安全上下文中依赖的UserProviderInterface
实现的refreshUser
方法。
请参考以下 API 文档:
UserProviderInterface.html#method_refreshUser
由实现决定是否应 完全重新加载(例如从数据库),或者如果用户界面 对象可以合并到用户/身份的某个内部数组中 地图。