是 - Sitecore执行此操作的方法是将用户详细信息添加到缓存键以进行渲染.这是存储在html缓存中,因此要清除它,您需要获取html缓存并清除包含用户名的所有条目.
这个代码片段会这样做:
// Need to clear the cache for the header and the user profile....
var htmlCache = CacheManager.GetHtmlCache(Context.Site);
// Remove all cache keys that contain the currently logged in user.
var cacheKey = $"#login:True_#user:{Context.GetUserName()}";
htmlCache.RemoveKeysContaining(cacheKey);
Run Code Online (Sandbox Code Playgroud)
这将清除当前登录用户的html缓存中的所有条目.如果要清除其他用户,只需更改Context.GetUserName()
以获取要清除的特定用户.
归档时间: |
|
查看次数: |
436 次 |
最近记录: |