移除部分配置,添加说明
This commit is contained in:
parent
d8f646a0d3
commit
08c511964c
|
@ -271,8 +271,9 @@ namespace Sample.MySql.Controllers
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IActionResult> Get8()
|
public async Task<IActionResult> Get8()
|
||||||
{
|
{
|
||||||
var list = new List<string>();
|
var sysUserMod = await _defaultTableDbContext.Set<SysUserMod>().AsNoTracking().FirstOrDefaultAsync();
|
||||||
var sysUserMod = await _defaultTableDbContext.Set<SysTest>().Where(o => list.Contains(o.Id)).ToListAsync();
|
_defaultTableDbContext.Update(sysUserMod);
|
||||||
|
await _defaultTableDbContext.SaveChangesAsync();
|
||||||
// var sysUserMods1 = await _defaultTableDbContext.Set<SysUserMod>().FromSqlRaw("select * from SysUserMod where id='2'").ToListAsync();
|
// var sysUserMods1 = await _defaultTableDbContext.Set<SysUserMod>().FromSqlRaw("select * from SysUserMod where id='2'").ToListAsync();
|
||||||
// var sysUserMods2 = await _defaultTableDbContext.Set<SysTest>().FromSqlRaw("select * from SysTest where id='2'").ToListAsync();
|
// var sysUserMods2 = await _defaultTableDbContext.Set<SysTest>().FromSqlRaw("select * from SysTest where id='2'").ToListAsync();
|
||||||
return Ok();
|
return Ok();
|
||||||
|
|
|
@ -86,11 +86,11 @@ namespace Sample.MySql
|
||||||
}));
|
}));
|
||||||
}).UseConfig((sp,o) =>
|
}).UseConfig((sp,o) =>
|
||||||
{
|
{
|
||||||
var memoryCache = sp.ApplicationServiceProvider.GetRequiredService<IMemoryCache>();
|
// var memoryCache = sp.ApplicationServiceProvider.GetRequiredService<IMemoryCache>();
|
||||||
o.UseExecutorDbContextConfigure(b =>
|
// o.UseExecutorDbContextConfigure(b =>
|
||||||
{
|
// {
|
||||||
b.UseMemoryCache(memoryCache);
|
// b.UseMemoryCache(memoryCache);
|
||||||
});
|
// });
|
||||||
o.UseEntityFrameworkCoreProxies = true;
|
o.UseEntityFrameworkCoreProxies = true;
|
||||||
o.CacheModelLockConcurrencyLevel = 1024;
|
o.CacheModelLockConcurrencyLevel = 1024;
|
||||||
o.CacheEntrySize = 1;
|
o.CacheEntrySize = 1;
|
||||||
|
|
|
@ -30,9 +30,7 @@ namespace ShardingCore.Core.ModelCacheLockerProviders
|
||||||
|
|
||||||
public int GetCacheModelLockObjectSeconds()
|
public int GetCacheModelLockObjectSeconds()
|
||||||
{
|
{
|
||||||
if (_shardingConfigOptions.ModelCacheLockObjectSeconds == 3)
|
return _shardingConfigOptions.CacheModelLockObjectSeconds;
|
||||||
return _shardingConfigOptions.CacheModelLockObjectSeconds;
|
|
||||||
return _shardingConfigOptions.ModelCacheLockObjectSeconds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !EFCORE2
|
#if !EFCORE2
|
||||||
|
|
|
@ -17,8 +17,6 @@ namespace ShardingCore.Core.ShardingConfigurations
|
||||||
/// 模型缓存锁等待时间
|
/// 模型缓存锁等待时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int CacheModelLockObjectSeconds { get; set; } = 3;
|
public int CacheModelLockObjectSeconds { get; set; } = 3;
|
||||||
[Obsolete("plz use CacheModelLockObjectSeconds")]
|
|
||||||
public int ModelCacheLockObjectSeconds { get; set; } = 3;
|
|
||||||
#if !EFCORE2
|
#if !EFCORE2
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 模型缓存的优先级
|
/// 模型缓存的优先级
|
||||||
|
@ -27,7 +25,7 @@ namespace ShardingCore.Core.ShardingConfigurations
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// efcore缓存最多限制10240个,单个缓存size设置为10那么就意味可以最多统一时间缓存1024个(缓存过期了那么还是会可以缓存进去的)
|
/// efcore缓存最多限制10240个,单个缓存size设置为10那么就意味可以最多统一时间缓存1024个(缓存过期了那么还是会可以缓存进去的)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int CacheEntrySize { get; set; } = 10;
|
public int CacheEntrySize { get; set; } = 1;
|
||||||
#endif
|
#endif
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 模型缓存锁等级
|
/// 模型缓存锁等级
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace ShardingCore.Sharding
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分表分库的dbcontext
|
/// 分表分库的dbContext
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class AbstractShardingDbContext : DbContext, IShardingDbContext
|
public abstract class AbstractShardingDbContext : DbContext, IShardingDbContext
|
||||||
{
|
{
|
||||||
|
@ -36,6 +36,10 @@ namespace ShardingCore.Sharding
|
||||||
}
|
}
|
||||||
|
|
||||||
private IShardingDbContextExecutor _shardingDbContextExecutor;
|
private IShardingDbContextExecutor _shardingDbContextExecutor;
|
||||||
|
/// <summary>
|
||||||
|
/// 分片执行者
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public IShardingDbContextExecutor GetShardingExecutor()
|
public IShardingDbContextExecutor GetShardingExecutor()
|
||||||
{
|
{
|
||||||
if (!_createExecutor)
|
if (!_createExecutor)
|
||||||
|
|
|
@ -9,6 +9,9 @@ namespace ShardingCore.Sharding.Abstractions
|
||||||
* @Ver: 1.0
|
* @Ver: 1.0
|
||||||
* @Email: 326308290@qq.com
|
* @Email: 326308290@qq.com
|
||||||
*/
|
*/
|
||||||
|
/// <summary>
|
||||||
|
/// 实现该接口让dbContext支持分表功能
|
||||||
|
/// </summary>
|
||||||
public interface IShardingTableDbContext
|
public interface IShardingTableDbContext
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace ShardingCore.Sharding.MergeEngines
|
||||||
}
|
}
|
||||||
public TEntity MergeResult()
|
public TEntity MergeResult()
|
||||||
{
|
{
|
||||||
//将toke改成1
|
//将take改成1
|
||||||
var asyncEnumeratorStreamMergeEngine = new AsyncEnumeratorStreamMergeEngine<TEntity>(_streamMergeContext);
|
var asyncEnumeratorStreamMergeEngine = new AsyncEnumeratorStreamMergeEngine<TEntity>(_streamMergeContext);
|
||||||
var list = asyncEnumeratorStreamMergeEngine.ToStreamList();
|
var list = asyncEnumeratorStreamMergeEngine.ToStreamList();
|
||||||
return list.FirstOrDefault();
|
return list.FirstOrDefault();
|
||||||
|
@ -33,7 +33,7 @@ namespace ShardingCore.Sharding.MergeEngines
|
||||||
|
|
||||||
public async Task<TEntity> MergeResultAsync(CancellationToken cancellationToken = new CancellationToken())
|
public async Task<TEntity> MergeResultAsync(CancellationToken cancellationToken = new CancellationToken())
|
||||||
{
|
{
|
||||||
//将toke改成1
|
//将take改成1
|
||||||
var asyncEnumeratorStreamMergeEngine = new AsyncEnumeratorStreamMergeEngine<TEntity>(_streamMergeContext);
|
var asyncEnumeratorStreamMergeEngine = new AsyncEnumeratorStreamMergeEngine<TEntity>(_streamMergeContext);
|
||||||
|
|
||||||
var take = _streamMergeContext.GetTake();
|
var take = _streamMergeContext.GetTake();
|
||||||
|
|
|
@ -276,7 +276,7 @@ namespace ShardingCore
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自动尝试补偿表
|
/// 自动尝试补偿表,自行判断缺少的分片对象(包括分表或者分库)并且会自动创建对应的数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="serviceProvider"></param>
|
/// <param name="serviceProvider"></param>
|
||||||
/// <param name="parallelCount"></param>
|
/// <param name="parallelCount"></param>
|
||||||
|
|
Loading…
Reference in New Issue