We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change code like this public static dynamic GetPersonalEntity(string redisKey, out CacheItemSet itemSet) { itemSet = null; dynamic entity = null; KeyValuePair<string, CacheItemSet> itemPair; if (TryGetContainerCacheItem(redisKey, out itemPair)) { itemSet = itemPair.Value; if (itemSet != null) { switch (itemPair.Value.ItemType) { case CacheType.Entity: entity = itemPair.Value.ItemData; break; case CacheType.Dictionary: var set = itemPair.Value.ItemData as BaseCollection; if (set != null) { set.TryGetValue(itemPair.Key, out entity); } break; default: TraceLog.WriteError("Not suported CacheType:{0} for GetPersonalEntity key:{1}", itemPair.Value.ItemType, redisKey); break; } } } if (entity == null) { //while is remove entity is empty. //TraceLog.WriteComplement("GetPersonalEntity key:{0} is empty.", redisKey); } return entity; }
public static dynamic GetPersonalEntity(string redisKey, out CacheItemSet itemSet) { itemSet = null; dynamic entity = null; KeyValuePair<string, CacheItemSet> itemPair; if (TryGetContainerCacheItem(redisKey, out itemPair)) { itemSet = itemPair.Value; if (itemSet != null) { switch (itemPair.Value.ItemType) { case CacheType.Entity: entity = itemPair.Value.ItemData; break; case CacheType.Dictionary: var set = itemPair.Value.ItemData as BaseCollection; if (set != null) { set.TryGetValue(itemPair.Key, out entity); } break; default: TraceLog.WriteError("Not suported CacheType:{0} for GetPersonalEntity key:{1}", itemPair.Value.ItemType, redisKey); break; } } } if (entity == null) { //while is remove entity is empty. //TraceLog.WriteComplement("GetPersonalEntity key:{0} is empty.", redisKey); } return entity; }
`public static bool TryGetContainerCacheItem(string redisKey, out KeyValuePair<string, CacheItemSet> itemPair, int periodTime = 0) { itemPair = default(KeyValuePair<string, CacheItemSet>); CacheItemSet cacheItem; string[] keys = (redisKey ?? "").Split('_'); if (keys.Length == 2 && !string.IsNullOrEmpty(keys[0])) { CacheContainer container = null; string typeName = RedisConnectionPool.DecodeTypeName(keys[0]); var schema = EntitySchemaSet.Get(typeName); periodTime = periodTime > 0 ? periodTime : schema.PeriodTime; if (_writePools != null && !_writePools.TryGetValue(typeName, out container)) { _writePools.InitContainer(typeName); _writePools.TryGetValue(typeName, out container); } if (container == null) return false;
string[] childKeys = keys[1].Split('|'); string personalKey = childKeys[0]; string entityKey = childKeys.Length > 1 ? childKeys[1] : ""; if (schema.CacheType == CacheType.Dictionary || schema.CacheType == CacheType.Entity) { container.Collection.TryGetValue(personalKey, out cacheItem); itemPair = new KeyValuePair<string, CacheItemSet>(entityKey, cacheItem); return true; } if (schema.CacheType == CacheType.Entity) { container.Collection.TryGetValue(entityKey, out cacheItem); itemPair = new KeyValuePair<string, CacheItemSet>(entityKey, cacheItem); return true; } if (schema.CacheType == CacheType.Queue) { TraceLog.WriteError("Not support CacheType.Queue get cache, key:{0}.", redisKey); } ////存在分类id与实体主键相同情况, 要优先判断实体主键 //if (!string.IsNullOrEmpty(personalKey) && container.Collection.TryGetValue(entityKey, out cacheItem)) //{ // itemPair = new KeyValuePair<string, CacheItemSet>(entityKey, cacheItem); // return true; //} //if (!string.IsNullOrEmpty(personalKey) && container.Collection.TryGetValue(personalKey, out cacheItem)) //{ // itemPair = new KeyValuePair<string, CacheItemSet>(entityKey, cacheItem); // return true; //} } return false; }`
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Change code like this
public static dynamic GetPersonalEntity(string redisKey, out CacheItemSet itemSet) { itemSet = null; dynamic entity = null; KeyValuePair<string, CacheItemSet> itemPair; if (TryGetContainerCacheItem(redisKey, out itemPair)) { itemSet = itemPair.Value; if (itemSet != null) { switch (itemPair.Value.ItemType) { case CacheType.Entity: entity = itemPair.Value.ItemData; break; case CacheType.Dictionary: var set = itemPair.Value.ItemData as BaseCollection; if (set != null) { set.TryGetValue(itemPair.Key, out entity); } break; default: TraceLog.WriteError("Not suported CacheType:{0} for GetPersonalEntity key:{1}", itemPair.Value.ItemType, redisKey); break; } } } if (entity == null) { //while is remove entity is empty. //TraceLog.WriteComplement("GetPersonalEntity key:{0} is empty.", redisKey); } return entity; }
`public static bool TryGetContainerCacheItem(string redisKey, out KeyValuePair<string, CacheItemSet> itemPair, int periodTime = 0)
{
itemPair = default(KeyValuePair<string, CacheItemSet>);
CacheItemSet cacheItem;
string[] keys = (redisKey ?? "").Split('_');
if (keys.Length == 2 && !string.IsNullOrEmpty(keys[0]))
{
CacheContainer container = null;
string typeName = RedisConnectionPool.DecodeTypeName(keys[0]);
var schema = EntitySchemaSet.Get(typeName);
periodTime = periodTime > 0 ? periodTime : schema.PeriodTime;
if (_writePools != null && !_writePools.TryGetValue(typeName, out container))
{
_writePools.InitContainer(typeName);
_writePools.TryGetValue(typeName, out container);
}
if (container == null) return false;
The text was updated successfully, but these errors were encountered: