コード例 #1
0
 public LightweightCache <List <TopOperation> > GetTopOperations(TopSearchOptions options = null)
 {
     return(TimedCache(nameof(GetTopOperations) + "-" + (options?.GetHashCode() ?? 0).ToString(),
                       conn =>
     {
         var hasOptions = options != null;
         var sql = string.Format(GetFetchSQL <TopOperation>(),
                                 hasOptions ? options.ToSQLWhere() + options.ToSQLOrder() : "",
                                 hasOptions ? options.ToSQLSearch() : "");
         sql = sql.Replace("query_plan AS QueryPlan,", "")
               .Replace("CROSS APPLY sys.dm_exec_query_plan(PlanHandle) AS qp", "");
         return conn.Query <TopOperation>(sql, options).AsList();
     }, 10.Seconds(), 5.Minutes()));
 }
コード例 #2
0
 public Cache<List<TopOperation>> GetTopOperations(TopSearchOptions options = null)
 {
     return new Cache<List<TopOperation>>
         {
             CacheKey = GetCacheKey("TopOperations-" + (options == null ? 0 : options.GetHashCode())),
             CacheForSeconds = 15,
             CacheStaleForSeconds = 5*60,
             UpdateCache = UpdateFromSql("Top Operations", conn =>
                 {
                     var sql = TopOperation.FetchSQL + (options != null ? options.ToSQLWhere() + options.ToSQLOrder() : "");
                     return conn.Query<TopOperation>(sql, options).ToList();
                 })
         };
 }
コード例 #3
0
 public Cache <List <TopOperation> > GetTopOperations(TopSearchOptions options = null)
 {
     return(Cache <List <TopOperation> > .WithKey(
                GetCacheKey(nameof(GetTopOperations) + "-" + (options?.GetHashCode() ?? 0).ToString()),
                UpdateFromSql("Top Operations", conn =>
     {
         var hasOptions = options != null;
         var sql = string.Format(GetFetchSQL <TopOperation>(),
                                 hasOptions ? options.ToSQLWhere() + options.ToSQLOrder() : "",
                                 hasOptions ? options.ToSQLSearch() : "");
         sql = sql.Replace("query_plan AS QueryPlan,", "")
               .Replace("CROSS APPLY sys.dm_exec_query_plan(PlanHandle) AS qp", "");
         return conn.QueryAsync <TopOperation>(sql, options);
     }),
                15, 5 *60));
 }
コード例 #4
0
 public Cache<List<TopOperation>> GetTopOperations(TopSearchOptions options = null)
 {
     return new Cache<List<TopOperation>>
     {
         CacheKey = GetCacheKey("TopOperations-" + (options == null ? 0 : options.GetHashCode())),
         CacheForSeconds = 15,
         CacheStaleForSeconds = 5*60,
         UpdateCache = UpdateFromSql("Top Operations", conn =>
         {
             var hasOptions = options != null;
             var sql = string.Format(GetFetchSQL<TopOperation>(),
                 (hasOptions ? options.ToSQLWhere() + options.ToSQLOrder() : ""),
                 (hasOptions ? options.ToSQLSearch() : ""));
             sql = sql.Replace("query_plan AS QueryPlan,", "");
             return conn.Query<TopOperation>(sql, options).ToList();
         })
     };
 }
コード例 #5
0
 public Cache <List <TopOperation> > GetTopOperations(TopSearchOptions options = null)
 {
     return(new Cache <List <TopOperation> >
     {
         CacheKey = GetCacheKey("TopOperations-" + (options?.GetHashCode() ?? 0)),
         CacheForSeconds = 15,
         CacheStaleForSeconds = 5 * 60,
         UpdateCache = UpdateFromSql("Top Operations", conn =>
         {
             var hasOptions = options != null;
             var sql = string.Format(GetFetchSQL <TopOperation>(),
                                     (hasOptions ? options.ToSQLWhere() + options.ToSQLOrder() : ""),
                                     (hasOptions ? options.ToSQLSearch() : ""));
             sql = sql.Replace("query_plan AS QueryPlan,", "")
                   .Replace("CROSS APPLY sys.dm_exec_query_plan(PlanHandle) AS qp", "");
             return conn.QueryAsync <TopOperation>(sql, options);
         })
     });
 }
コード例 #6
0
 public Cache<List<TopOperation>> GetTopOperations(TopSearchOptions options = null)
 {
     return new Cache<List<TopOperation>>
     {
         CacheKey = GetCacheKey("TopOperations-" + (options?.GetHashCode() ?? 0)),
         CacheForSeconds = 15,
         CacheStaleForSeconds = 5*60,
         UpdateCache = UpdateFromSql("Top Operations", conn =>
         {
             var hasOptions = options != null;
             var sql = string.Format(GetFetchSQL<TopOperation>(),
                 (hasOptions ? options.ToSQLWhere() + options.ToSQLOrder() : ""),
                 (hasOptions ? options.ToSQLSearch() : ""));
             sql = sql.Replace("query_plan AS QueryPlan,", "")
                      .Replace("CROSS APPLY sys.dm_exec_query_plan(PlanHandle) AS qp", "");
             return conn.QueryAsync<TopOperation>(sql, options);
         })
     };
 }
コード例 #7
0
 public Cache <List <TopOperation> > GetTopOperations(TopSearchOptions options = null)
 {
     return(new Cache <List <TopOperation> >
     {
         CacheKey = GetCacheKey("TopOperations-" + (options == null ? 0 : options.GetHashCode())),
         CacheForSeconds = 15,
         CacheStaleForSeconds = 5 * 60,
         UpdateCache = UpdateFromSql("Top Operations", conn =>
         {
             var sql = string.Format(GetFetchSQL <TopOperation>(), (options != null ? options.ToSQLWhere() + options.ToSQLOrder() : ""));
             sql = sql.Replace("query_plan AS QueryPlan,", "");
             return conn.Query <TopOperation>(sql, options).ToList();
         })
     });
 }