1、Couchbase緩存
使用CacheManager組件,在配置Couchbase緩存支持時,因爲對配置節cache handle命名規則要求不瞭解,費了點時間查了源碼才明白。 ide
section配置節memcached
<sectionGroup name="couchbaseClients"> <section name="couchbase" type="Couchbase.Configuration.Client.Providers.CouchbaseClientSection, Couchbase.NetClient" /> </sectionGroup>
cacheManager中的cache節點配置this
<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下的couchbasespa
Bucket名爲可選,默認爲defaultcode
格式爲<configKey>:<bucketName>orm
源碼參考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);
2、memcachedit
memcached配置時,對cacheManager中的cache節點handle的命名也和Couchbase類型,配置以下io
<sectionGroup name="enyim.com"> <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching" /> </sectionGroup>
<managers> <cache name="cacheName" updateMode="Up" enableStatistics="false" enablePerformanceCounters="false"> <handle name="enyim.com/memcached" ref="memcachedHandle"/> </cache> </managers>
或者
<managers> <cache name="cacheName" updateMode="Up" enableStatistics="false" enablePerformanceCounters="false"> <handle name="default" ref="memcachedHandle"/> </cache> </managers>handle命名爲 enyim.com/memcached或 default,default時組件自動爲轉化爲enyim.com/memcached