Add RemoveDataCache

This commit is contained in:
sunkaixuan 2017-10-10 19:58:57 +08:00
parent 228db65a9a
commit a2ad14b3bc
9 changed files with 31 additions and 5 deletions

View File

@ -173,6 +173,14 @@ namespace SqlSugar
DeleteBuilder.Parameters.AddRange(parameters); DeleteBuilder.Parameters.AddRange(parameters);
return this; return this;
} }
public IDeleteable<T> RemoveDataCache()
{
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
CacheSchemeMain.RemoveCache(cacheService, this.Context.EntityMaintenance.GetTableName<T>());
return this;
}
public IDeleteable<T> In<PkType>(List<PkType> primaryKeyValues) public IDeleteable<T> In<PkType>(List<PkType> primaryKeyValues)
{ {
if (primaryKeyValues == null || primaryKeyValues.Count() == 0) if (primaryKeyValues == null || primaryKeyValues.Count() == 0)

View File

@ -184,6 +184,13 @@ namespace SqlSugar
this.InsertBuilder.IsNoInsertNull = isNoInsertNull; this.InsertBuilder.IsNoInsertNull = isNoInsertNull;
return this; return this;
} }
public IInsertable<T> RemoveDataCache()
{
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
CacheSchemeMain.RemoveCache(cacheService, this.Context.EntityMaintenance.GetTableName<T>());
return this;
}
#endregion #endregion
#region Protected Methods #region Protected Methods

View File

@ -1032,7 +1032,7 @@ namespace SqlSugar
var sqlObj = this.ToSql(); var sqlObj = this.ToSql();
if (IsCache) if (IsCache)
{ {
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCache; var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
result = CacheSchemeMain.GetOrCreate<List<TResult>>(cacheService, this.QueryBuilder, () => { return GetData<TResult>(sqlObj); }, CacheTime, this.Context); result = CacheSchemeMain.GetOrCreate<List<TResult>>(cacheService, this.QueryBuilder, () => { return GetData<TResult>(sqlObj); }, CacheTime, this.Context);
} }
else else

View File

@ -174,6 +174,7 @@ namespace SqlSugar
UpdateBuilder.WhereValues.Add(expResult.GetResultString()); UpdateBuilder.WhereValues.Add(expResult.GetResultString());
return this; return this;
} }
public IUpdateable<T> With(string lockString) public IUpdateable<T> With(string lockString)
{ {
if (this.Context.CurrentConnectionConfig.DbType == DbType.SqlServer) if (this.Context.CurrentConnectionConfig.DbType == DbType.SqlServer)
@ -181,6 +182,13 @@ namespace SqlSugar
return this; return this;
} }
public IUpdateable<T> RemoveDataCache()
{
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
CacheSchemeMain.RemoveCache(cacheService, this.Context.EntityMaintenance.GetTableName<T>());
return this;
}
internal void Init() internal void Init()
{ {
this.UpdateBuilder.TableName = EntityInfo.EntityName; this.UpdateBuilder.TableName = EntityInfo.EntityName;

View File

@ -49,7 +49,7 @@ namespace SqlSugar
set{ _SerializeService = value;} set{ _SerializeService = value;}
} }
public ICacheService ReflectionInoCache public ICacheService ReflectionInoCacheService
{ {
get get
{ {
@ -61,7 +61,7 @@ namespace SqlSugar
set{_ReflectionInoCache = value;} set{_ReflectionInoCache = value;}
} }
public ICacheService DataInfoCache public ICacheService DataInfoCacheService
{ {
get get
{ {

View File

@ -272,7 +272,7 @@ namespace SqlSugar
#region Cache #region Cache
public ICacheService GetReflectionInoCacheInstance() public ICacheService GetReflectionInoCacheInstance()
{ {
return Context.CurrentConnectionConfig.ConfigureExternalServices.ReflectionInoCache; return Context.CurrentConnectionConfig.ConfigureExternalServices.ReflectionInoCacheService;
} }
public void RemoveCacheAll() public void RemoveCacheAll()

View File

@ -26,6 +26,7 @@ namespace SqlSugar
IDeleteable<T> Where(string whereString, SugarParameter parameter); IDeleteable<T> Where(string whereString, SugarParameter parameter);
IDeleteable<T> Where(string whereString, SugarParameter[] parameters); IDeleteable<T> Where(string whereString, SugarParameter[] parameters);
IDeleteable<T> Where(string whereString, List<SugarParameter> parameters); IDeleteable<T> Where(string whereString, List<SugarParameter> parameters);
IDeleteable<T> RemoveDataCache();
KeyValuePair<string, List<SugarParameter>> ToSql(); KeyValuePair<string, List<SugarParameter>> ToSql();
} }
} }

View File

@ -30,6 +30,7 @@ namespace SqlSugar
IUpdateable<T> IgnoreColumns(Expression<Func<T, object>> columns); IUpdateable<T> IgnoreColumns(Expression<Func<T, object>> columns);
IUpdateable<T> IgnoreColumns(Func<string, bool> ignoreColumMethod); IUpdateable<T> IgnoreColumns(Func<string, bool> ignoreColumMethod);
IUpdateable<T> ReSetValue(Expression<Func<T, bool>> setValueExpression); IUpdateable<T> ReSetValue(Expression<Func<T, bool>> setValueExpression);
IUpdateable<T> RemoveDataCache();
KeyValuePair<string,List<SugarParameter>> ToSql(); KeyValuePair<string,List<SugarParameter>> ToSql();
} }
} }

View File

@ -27,6 +27,7 @@ namespace SqlSugar
IInsertable<T> IgnoreColumns(Expression<Func<T, object>> columns); IInsertable<T> IgnoreColumns(Expression<Func<T, object>> columns);
IInsertable<T> IgnoreColumns(Func<string,bool> ignoreColumMethod); IInsertable<T> IgnoreColumns(Func<string,bool> ignoreColumMethod);
IInsertable<T> Where(bool isInsertNull, bool isOffIdentity = false); IInsertable<T> Where(bool isInsertNull, bool isOffIdentity = false);
IInsertable<T> RemoveDataCache();
KeyValuePair<string, List<SugarParameter>> ToSql(); KeyValuePair<string, List<SugarParameter>> ToSql();
} }
} }