cacheKey
cacheKey = $”{befforeCacheKey}|{afterCacheKey}”.Replace(“|”, “AAAAA”).Replace(“-“, “BBBBBB”);
private string SetCacheKey(PFGlobalParameter pfParams, Dictionary<string, object> dictionaryUrl)
{
if (!string.IsNullOrEmpty(pfParams.DimCacheKey))
{
if (dictionaryUrl.ContainsKey("_userc"))
{
pfParams.UserId = dictionaryUrl["_userId"]?.ToString();
return _guidRepository.Md5Guid($"{pfParams.OwnerId}-{pfParams.SysId}-{pfParams.ModuleKey}--{pfParams.DimCacheKey}-{pfParams.UserId}");
}
//return _guidRepository.SignatureGuid($"{pfParams.OwnerId}-{pfParams.SysId}-{pfParams.ModuleKey}--{pfParams.DimCacheKey}");
return _guidRepository.Md5Guid($"{pfParams.OwnerId}-{pfParams.SysId}-{pfParams.ModuleKey}--{pfParams.DimCacheKey}");
}
string cacheKey;
string tempCacheKey = null;
string userId = null;
string pageSize = null;
string pageIndex = null;
string _nodejs = null;
//页面传递过来的参数
if (dictionaryUrl.ContainsKey("_cache")) tempCacheKey = dictionaryUrl["_cache"]?.ToString();
if (dictionaryUrl.ContainsKey("pageSize")) pageSize = dictionaryUrl["pageSize"]?.ToString();
if (dictionaryUrl.ContainsKey("pageIndex")) pageIndex = dictionaryUrl["pageIndex"]?.ToString();
if (dictionaryUrl.ContainsKey("_nodejs")) _nodejs = dictionaryUrl["_nodejs"]?.ToString();
string befforeCacheKey = null;
//缓存添加上 用户id
if (dictionaryUrl.ContainsKey("_userc"))
{
pfParams.UserId = dictionaryUrl["_userId"]?.ToString();
befforeCacheKey = GetBefforeCacheKey(pfParams, true);
}
else
{
befforeCacheKey = GetBefforeCacheKey(pfParams, false);
}
string afterCacheKey = null;
if (pfParams.RequestModuleType == RequestModuleType.Detail)
{
//afterCacheKey = _guidRepository.SignatureGuid(tempCacheKey) + _guidRepository.SignatureGuid($"{pfParams.ReponseField}|{_nodejs ?? "_nodejs"}");
afterCacheKey = _guidRepository.Md5Guid(tempCacheKey) + _guidRepository.SignatureGuid($"{pfParams.ReponseField}|{_nodejs ?? "_nodejs"}");
}
else
{
//afterCacheKey = _guidRepository.SignatureGuid($"{pfParams.ReponseField}|{tempCacheKey}|{userId ?? "userid"}|{pageIndex ?? "pageindex"}|{pageSize ?? "pagesize"}|{_nodejs ?? "_nodejs"}|{pfParams.ColumnField ?? "folumnfield"}");
afterCacheKey = _guidRepository.Md5Guid($"{pfParams.ReponseField}|{tempCacheKey}|{userId ?? "userid"}|{pageIndex ?? "pageindex"}|{pageSize ?? "pagesize"}|{_nodejs ?? "_nodejs"}|{pfParams.ColumnField ?? "folumnfield"}");
}
#region 存储前缀的数据信息,用于清空缓存
List<string> lstKeys = _dataResultCache.Get<List<string>>(befforeCacheKey);
cacheKey = $"{befforeCacheKey}|{afterCacheKey}".Replace("|", "AAAAA").Replace("-", "BBBBBB");
if (lstKeys == null)
{
lstKeys = new List<string>();
}
if (!lstKeys.Contains(cacheKey))
{
lstKeys.Add(cacheKey);
_dataResultCache.Set<List<string>>(befforeCacheKey, lstKeys);
}
#endregion
return cacheKey;
}
文档更新时间: 2022-03-02 17:11 作者:admin