This commit is contained in:
parent
61f76b7b19
commit
f09306530b
|
@ -57,15 +57,14 @@ namespace ShardingCore.EFCores
|
|||
}
|
||||
|
||||
int waitSeconds = 3;
|
||||
if (context is IShardingModelCacheOption shardingModelCacheOption)
|
||||
{
|
||||
waitSeconds = shardingModelCacheOption.GetModelCacheLockObjectSeconds();
|
||||
}
|
||||
|
||||
var cacheKey = Dependencies.ModelCacheKeyFactory.Create(context);
|
||||
if (!_models.TryGetValue(cacheKey, out var model))
|
||||
{
|
||||
|
||||
if (context is IShardingModelCacheOption shardingModelCacheOption)
|
||||
{
|
||||
waitSeconds = shardingModelCacheOption.GetModelCacheLockObjectSeconds();
|
||||
}
|
||||
var acquire = Monitor.TryEnter(_syncObject, TimeSpan.FromSeconds(waitSeconds));
|
||||
if (!acquire)
|
||||
{
|
||||
|
|
|
@ -67,16 +67,16 @@ namespace ShardingCore.EFCores
|
|||
priority = CacheItemPriority.Normal;
|
||||
}
|
||||
}
|
||||
if (context is IShardingModelCacheOption shardingModelCacheOption)
|
||||
{
|
||||
priority = shardingModelCacheOption.GetModelCachePriority();
|
||||
size = shardingModelCacheOption.GetModelCacheEntrySize();
|
||||
waitSeconds = shardingModelCacheOption.GetModelCacheLockObjectSeconds();
|
||||
}
|
||||
var cache = Dependencies.MemoryCache;
|
||||
var cacheKey = Dependencies.ModelCacheKeyFactory.Create(context);
|
||||
if (!cache.TryGetValue(cacheKey, out IModel model))
|
||||
{
|
||||
if (context is IShardingModelCacheOption shardingModelCacheOption)
|
||||
{
|
||||
priority = shardingModelCacheOption.GetModelCachePriority();
|
||||
size = shardingModelCacheOption.GetModelCacheEntrySize();
|
||||
waitSeconds = shardingModelCacheOption.GetModelCacheLockObjectSeconds();
|
||||
}
|
||||
// Make sure OnModelCreating really only gets called once, since it may not be thread safe.
|
||||
|
||||
var acquire = Monitor.TryEnter(_syncObject, TimeSpan.FromSeconds(waitSeconds));
|
||||
|
|
|
@ -83,16 +83,16 @@ namespace ShardingCore.EFCores
|
|||
priority = CacheItemPriority.Normal;
|
||||
}
|
||||
}
|
||||
if (context is IShardingModelCacheOption shardingModelCacheOption)
|
||||
{
|
||||
priority = shardingModelCacheOption.GetModelCachePriority();
|
||||
size = shardingModelCacheOption.GetModelCacheEntrySize();
|
||||
waitSeconds = shardingModelCacheOption.GetModelCacheLockObjectSeconds();
|
||||
}
|
||||
var cache = Dependencies.MemoryCache;
|
||||
var cacheKey = Dependencies.ModelCacheKeyFactory.Create(context);
|
||||
if (!cache.TryGetValue(cacheKey, out IModel model))
|
||||
{
|
||||
if (context is IShardingModelCacheOption shardingModelCacheOption)
|
||||
{
|
||||
priority = shardingModelCacheOption.GetModelCachePriority();
|
||||
size = shardingModelCacheOption.GetModelCacheEntrySize();
|
||||
waitSeconds = shardingModelCacheOption.GetModelCacheLockObjectSeconds();
|
||||
}
|
||||
// Make sure OnModelCreating really only gets called once, since it may not be thread safe.
|
||||
var acquire = Monitor.TryEnter(_syncObject, TimeSpan.FromSeconds(waitSeconds));
|
||||
if (!acquire)
|
||||
|
|
|
@ -98,17 +98,16 @@ namespace ShardingCore.EFCores
|
|||
priority = CacheItemPriority.Normal;
|
||||
}
|
||||
}
|
||||
|
||||
if (context is IShardingModelCacheOption shardingModelCacheOption)
|
||||
{
|
||||
priority = shardingModelCacheOption.GetModelCachePriority();
|
||||
size = shardingModelCacheOption.GetModelCacheEntrySize();
|
||||
waitSeconds = shardingModelCacheOption.GetModelCacheLockObjectSeconds();
|
||||
}
|
||||
var cache = Dependencies.MemoryCache;
|
||||
var cacheKey = Dependencies.ModelCacheKeyFactory.Create(context, designTime);
|
||||
if (!cache.TryGetValue(cacheKey, out IModel model))
|
||||
{
|
||||
if (context is IShardingModelCacheOption shardingModelCacheOption)
|
||||
{
|
||||
priority = shardingModelCacheOption.GetModelCachePriority();
|
||||
size = shardingModelCacheOption.GetModelCacheEntrySize();
|
||||
waitSeconds = shardingModelCacheOption.GetModelCacheLockObjectSeconds();
|
||||
}
|
||||
// Make sure OnModelCreating really only gets called once, since it may not be thread safe.
|
||||
var acquire = Monitor.TryEnter(_syncObject, TimeSpan.FromSeconds(waitSeconds));
|
||||
if (!acquire)
|
||||
|
|
Loading…
Reference in New Issue