DevCache轻量级缓存组件

DevCache为MadAdmin开发平台的缓存组件,暂时包括文件缓存,内存缓存,MemCached,Redis四部分,代码都比较简单,有问题可自行修改源码解决。

详细API请参照源码,注意事项如下:
1.每种缓存都有自己的一些特殊配置参数。
2.由于每种缓存都有自己的特色,而在之前的项目中也是多种缓存配合使用,所以并没有提取公共接口出来。
3.以后可能会加入Tokoy Tyrant支持。
4.在缓存设置中建议设置KeyPrefix参数,建议形式为:“唯一项目标识.版本号.”,需要清除缓存时,版本号加1即可。
5.开发期间有时需要看到即时效果,可设置IsCache=”false”,使缓存失效。

 

//文件缓存
FileCache cache1=FileCacheClient.GetInstance("Default");
//内存缓存
MemoryCache cache2=MemoryCacheClient.GetInstance();
//MemCached
MemcachedClient cache = MemcachedClient.GetInstance("Default");
//Redis
RedisClient client = RedisClientFactory.GetInstance("Default");

Web.config

< ?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configsections>
    <section name="DevCache" type="DevCache.DevCacheSectionHandler,DevCache" />
  </configsections>

  <devcache>
    <filecached>
      <setting IsCache="true" />
      <add name="Default" FileCachePath="/FileCache/" KeyPrefix="" />
    </filecached>

    <memorycached>
      <setting IsCache="true" IntervalMinutes="1" ScavangeMinutes="60" MaxCount="1000000" MaxSize="100*1024" />
      <add name="Default" KeyPrefix="" />
    </memorycached>

    <memcached>
      <setting IsCache="true" SendReceiveTimeout="2000" MinPoolSize="5" MaxPoolSize="10" />
      <add name="Default" Hosts="127.0.0.1:11211" KeyPrefix="Default.001." />
      <add name="Second" Hosts="127.0.0.1:11211,127.0.0.1:11212" KeyPrefix="Second.001." />
      <add name="MyOther" Hosts="server1.example.com:12345, server2.example.com:12345, server3.example.com:12345" KeyPrefix="" />
    </memcached>

    <redis>
      <setting IsCache="true" SendTimeout="-1" />
      <add name="Default" Host="127.0.0.1" Port="6379" DefaultDB="0" />
      <add name="Second" Host="127.0.0.1" Port="6379" DefaultDB="1" />
    </redis>
  </devcache>
</configuration>

下载

来源:http://www.madcn.net/?p=529

转载于:https://www.cnblogs.com/HeroBeast/archive/2010/12/22/1913391.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值