How to store datatable in cache to reuse it?

后端 未结 4 1844
半阙折子戏
半阙折子戏 2020-12-01 08:34

In my application i have used Generic handler to serve requests.

I want mechanism like if the first time request comes to handler ,it makes a reques

4条回答
  •  温柔的废话
    2020-12-01 09:23

    you can write a property for your table like

    public DataTable CachedTable  { get{ 
          if(Cache["CachedTable"] == null) 
         { 
           Cache["CachedTable"]= //get from databse 
          } 
          return Cache["CachedTable"]; 
        }  }
    

提交回复
热议问题