Browse Source

Support RemoveDataCache by likeString

pull/1/MERGE
SUNKAIXUAN 4 years ago
parent
commit
6c85c49e4c
  1. 10
      Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs
  2. 9
      Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs
  3. 9
      Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs
  4. 18
      Src/Asp.Net/SqlSugar/CacheScheme/CacheSchemeMain.cs
  5. 1
      Src/Asp.Net/SqlSugar/Interface/IDeleteable.cs
  6. 1
      Src/Asp.Net/SqlSugar/Interface/IUpdateable.cs
  7. 1
      Src/Asp.Net/SqlSugar/Interface/Insertable.cs

10
Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs

@ -238,7 +238,15 @@ namespace SqlSugar
};
return this;
}
public IDeleteable<T> RemoveDataCache(string likeString)
{
this.RemoveCacheFunc = () =>
{
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
CacheSchemeMain.RemoveCache(cacheService, likeString);
};
return this;
}
public IDeleteable<T> In<PkType>(List<PkType> primaryKeyValues)
{
if (primaryKeyValues == null || primaryKeyValues.Count() == 0)

9
Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs

@ -228,6 +228,15 @@ namespace SqlSugar
};
return this;
}
public IInsertable<T> RemoveDataCache(string likeString)
{
this.RemoveCacheFunc = () =>
{
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
CacheSchemeMain.RemoveCache(cacheService, likeString);
};
return this;
}
public MySqlBlueCopy<T> UseMySql()
{
return new MySqlBlueCopy<T>(this.Context, this.SqlBuilder, InsertObjs);

9
Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs

@ -97,6 +97,15 @@ namespace SqlSugar
};
return this;
}
public IUpdateable<T> RemoveDataCache(string likeString)
{
this.RemoveCacheFunc = () =>
{
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
CacheSchemeMain.RemoveCache(cacheService,likeString);
};
return this;
}
public IUpdateable<T> IsEnableUpdateVersionValidation()
{
this.IsVersionValidation = true;

18
Src/Asp.Net/SqlSugar/CacheScheme/CacheSchemeMain.cs

@ -33,5 +33,23 @@ namespace SqlSugar
}
}
}
public static void RemoveCacheByLike(ICacheService cacheService, string likeString)
{
if (cacheService == null)
{
return;
}
var keys = cacheService.GetAllKey<string>();
if (keys.HasValue())
{
foreach (var item in keys)
{
if (item.ToLower().Contains(likeString))
{
cacheService.Remove<string>(item);
}
}
}
}
}
}

1
Src/Asp.Net/SqlSugar/Interface/IDeleteable.cs

@ -32,6 +32,7 @@ namespace SqlSugar
IDeleteable<T> WhereColumns(Expression<Func<T, object>> columns);
IDeleteable<T> EnableDiffLogEvent(object businessData = null);
IDeleteable<T> RemoveDataCache();
IDeleteable<T> RemoveDataCache(string likeString);
KeyValuePair<string, List<SugarParameter>> ToSql();
void AddQueue();
}

1
Src/Asp.Net/SqlSugar/Interface/IUpdateable.cs

@ -87,6 +87,7 @@ namespace SqlSugar
IUpdateable<T> EnableDiffLogEvent(object businessData = null);
IUpdateable<T> ReSetValue(Expression<Func<T, bool>> setValueExpression);
IUpdateable<T> RemoveDataCache();
IUpdateable<T> RemoveDataCache(string likeString);
IUpdateable<T> CallEntityMethod(Expression<Action<T>> method);
KeyValuePair<string,List<SugarParameter>> ToSql();
void AddQueue();

1
Src/Asp.Net/SqlSugar/Interface/Insertable.cs

@ -36,6 +36,7 @@ namespace SqlSugar
IInsertable<T> EnableDiffLogEvent(object businessData = null);
IInsertable<T> RemoveDataCache();
IInsertable<T> RemoveDataCache(string likeString);
KeyValuePair<string, List<SugarParameter>> ToSql();
SqlServerBlueCopy UseSqlServer();
MySqlBlueCopy<T> UseMySql();

Loading…
Cancel
Save