缓存会根据增删改更新吗? 返回

SqlSugar 老数据
2 2979

缓存数据会根据增删改数据库操作更新该缓存缓存吗?

热忱回答2

  • 删除缓存

    我们需要删除缓存也相当方便,只需要在对该表操作的时候加 RemoveDataCache 就能把查询中引用该表的缓存全部清除

      db.Deleteable<Student>().Where(it => it.Id == 1).RemoveDataCache().ExecuteCommand();


    0 回复
  • Damon Liu Damon Liu VIP0
    2017/11/22

    @fate stay night

    public class SingleDB

        {

            public static ICacheService myCache = new HttpRuntimeCache();//ICacheService

            private static ConnectionConfig config = new ConnectionConfig()

            {

                ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["DataBaseStr"].ConnectionString, //必填

                DbType = DbType.SqlServer, //必填

                IsAutoCloseConnection = true, //默认false

                InitKeyType = InitKeyType.SystemTable,//默认SystemTable;

                ConfigureExternalServices = new ConfigureExternalServices()

                {

                    DataInfoCacheService = myCache //Setting external cache service

                }

            }; 

            public static SqlSugarClient Instance

            {

                get

                {

                    return new SqlSugarClient(config);

                }

            }

            

        }


    请问当多用户访问SingleDB时我这样写会有线程安全吗?

    0 回复