asp.net 中如何维护数据缓存

分类: asp.net技巧   出处:iocblog整理  更新时间:2009-03-23   添加到收藏  

  在项目中我们经常会用到数据缓存,也会在项目处理对缓存的维护,但是有些时间我们需要人为的来维护这些缓存,用下面的代码来实现:
 
  1、将缓存信息绑定到datagrid上
 
 

private void bindcache() { string str = this.textbox1.text.trim(); datatable table = new datatable(); table.columns.add("cachename", typeof(string)); table.columns.add("cachetype", typeof(string)); idictionaryenumerator enumerator = httpruntime.cache.getenumerator(); int num = 0; while (enumerator.movenext()) { bool flag = true; if ((str != "") && (enumerator.key.tostring().indexof(str) < 0)) { flag = false; } if (flag) { num++; datarow row = table.newrow(); row["cachename"] = enumerator.key; row["cachetype"] = enumerator.value.gettype(); table.rows.add(row); } } this.label1.text = num.tostring().trim(); this.datagrid1.datasource = table; this.datagrid1.databind(); }

[1] [2] 下一页


Tag: 缓存



文章整理:iocblog
版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。