码迷,mamicode.com
首页 > 系统相关 > 详细

基于CacheManager组件的Couchbase配置

时间:2016-03-17 16:23:20      阅读:287      评论:0      收藏:0      [点我收藏+]

标签:

使用CacheManager组件,在配置Couchbase缓存支持时,由于对配置节cache handle命名规则要求不了解,费了点时间查了源码才明白。

section配置节

    <sectionGroup name="couchbaseClients">
      <section name="couchbase" type="Couchbase.Configuration.Client.Providers.CouchbaseClientSection, Couchbase.NetClient" />
    </sectionGroup>

cacheManager中的cache节点配置

    <managers>
      <cache name="cacheName" updateMode="Up" enableStatistics="false" enablePerformanceCounters="false">        
        <handle name="couchbaseClients/couchbase:default" ref="couchbaseHandle" expirationMode="Absolute" timeout="50s"/>
      </cache>
    </managers>
注意:

handleName的命名规则必须满足可通过配置名称找到CouchbaseClientSection对应配置节,即couchbaseClients下的couchbase

Bucket名为可选,默认为default

格式为<configKey>:<bucketName>

源码参考CacheManager.Couchbase.BucketCacheHandle

            // we can configure the bucket name by having "<configKey>:<bucketName>" as handle‘s
            // name value
            var nameParts = configuration.Key.Split(new[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
            Ensure(nameParts.Length > 0, "Handle key is not valid {0}", configuration.Key);

            this.configurationName = nameParts[0];

            if (nameParts.Length == 2)
            {
                this.bucketName = nameParts[1];
            }

            this.configuration = CouchbaseConfigurationManager.GetConfiguration(this.configurationName);
            this.bucketConfiguration = CouchbaseConfigurationManager.GetBucketConfiguration(this.configuration, this.bucketName);
            this.bucket = CouchbaseConfigurationManager.GetBucket(this.configuration, this.configurationName, this.bucketName);

基于CacheManager组件的Couchbase配置

标签:

原文地址:http://www.cnblogs.com/shijun/p/5287625.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!