实例介绍
CacheManager是一个针对.NET平台编写的C#语言的开源缓存抽象层,它支持多种缓存提供者,并且实现了众多的高级特性。其主要目的是为了让开发者能够更加轻松地处理即便是非常复杂的缓存场景。
通过使用CacheManager,开发者可以仅通过几行代码实现多层缓存,例如,在分布式缓存前面使用进程内缓存。CacheManager不仅仅是一个统一各种缓存提供者编程模型的接口,使得项目后期更改缓存策略变得非常容易,它还提供了额外的功能,如缓存同步、并发更新、序列化、事件、性能计数器等。
开发者可以根据需要选择加入这些功能。
CacheManager.Core
CacheManager.StackExchange.Redis
CacheManager.SystemRuntimeCaching
CacheManager.Microsoft.Extensions.Caching.Memory
CacheManager.Microsoft.Extensions.Configuration
CacheManager.Microsoft.Extensions.Logging
CacheManager.Serialization.DataContract
CacheManager.Serialization.Bond
CacheManager.Serialization.Json
CacheManager.Serialization.ProtoBuf
CacheManager.Web
CacheManager.Memcached
CacheManager.Couchbase
CacheManager支持从.NET Framework 4.5到.NET Standard 2.0的多个框架版本。它为不同的缓存技术提供了一个通用接口(ICache<T>),并且可以通过代码、Microsoft.Extensions.Configuration或App/Web.config进行配置。
CacheManager的序列化配置现在可以自定义,这在分布式缓存中尤为重要。如果没有安装并配置额外的序列化包,则将使用二进制序列化(如果可用)。当前可用的序列化选项包括基于Newtonsoft.Json库的Json、支持压缩的Json、基于Microsoft.Bond的Bond、基于System.Runtime.Serialization库的DataContract以及Google的Protocol Buffer等。
此外,CacheManager还提供了强类型缓存接口、多层缓存、缓存过期、缓存区域、统计信息、性能计数器和事件系统等特性,使得管理缓存变得更加灵活和高效。
【实例截图】
【核心代码】
文件清单
└── CacheManager-51bff815924179c6535dc88b7e2097022eb6a34f
├── appveyor.yml
├── Benchmarks.md
├── CacheManager.sln
├── CODE_OF_CONDUCT.md
├── COPYRIGHT.txt
├── _disable_.travis.yml
├── Documentation
│ ├── api
│ │ └── index.md
│ ├── apispec
│ │ ├── CacheManager_Core_CacheFactory_Build_System_String_System_Action_CacheManager_Core_ConfigurationBuilderCachePart__.md
│ │ ├── CacheManager_Core_JsonConfigurationBuilderExtensions.md
│ │ ├── CacheManager_Core_MicrosoftConfigurationExtensions.md
│ │ └── CacheManager_Core_MicrosoftLoggingBuilderExtensions.md
│ ├── build.cmd
│ ├── docfx.json
│ ├── GetMsdn.cmd
│ ├── index.md
│ ├── template
│ │ ├── ManagedReference.html.primary.tmpl
│ │ ├── partials
│ │ │ └── enum.tmpl.partial
│ │ └── toc.html.tmpl
│ └── toc.yml
├── LICENSE
├── NuGet.Config
├── README.md
├── samples
│ ├── AspnetCore.WebApp
│ │ ├── appsettings.json
│ │ ├── AspnetCore.WebApp.csproj
│ │ ├── cache.json
│ │ ├── Controllers
│ │ │ └── ValuesController.cs
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ ├── Startup.cs
│ │ └── web.config
│ ├── CacheManager.Examples
│ │ ├── App.config
│ │ ├── CacheManager.Examples.csproj
│ │ ├── Program.cs
│ │ └── Properties
│ │ └── AssemblyInfo.cs
│ ├── CacheManager.Examples.Configuration
│ │ ├── app.config
│ │ ├── CacheManager.Examples.Configuration.csproj
│ │ ├── Couchbase.cs
│ │ └── Program.cs
│ └── OutputCacheExample
│ ├── App_Start
│ │ ├── BundleConfig.cs
│ │ ├── FilterConfig.cs
│ │ └── RouteConfig.cs
│ ├── Content
│ │ └── Site.css
│ ├── Controllers
│ │ └── HomeController.cs
│ ├── favicon.ico
│ ├── Global.asax
│ ├── Global.asax.cs
│ ├── OutputCacheExample.csproj
│ ├── packages.config
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Views
│ │ ├── Home
│ │ │ ├── Index.cshtml
│ │ │ ├── PageA.cshtml
│ │ │ ├── PageB.cshtml
│ │ │ └── PageC.cshtml
│ │ ├── Shared
│ │ │ ├── Error.cshtml
│ │ │ └── _Layout.cshtml
│ │ ├── _ViewStart.cshtml
│ │ └── Web.config
│ ├── Web.config
│ ├── Web.Debug.config
│ └── Web.Release.config
├── src
│ ├── CacheManager.Core
│ │ ├── BaseCacheManager.cs
│ │ ├── BaseCacheManager.Expire.cs
│ │ ├── BaseCacheManager.GetOrAdd.cs
│ │ ├── BaseCacheManager.Update.cs
│ │ ├── CacheFactory.cs
│ │ ├── CacheHandleConfiguration.cs
│ │ ├── CacheItem.cs
│ │ ├── CacheManagerConfiguration.cs
│ │ ├── CacheManager.Core.csproj
│ │ ├── CacheUpdateMode.cs
│ │ ├── Configuration
│ │ │ ├── CacheManagerSection.cs
│ │ │ └── ConfigurationBuilder.cs
│ │ ├── ExpirationMode.cs
│ │ ├── ICache.cs
│ │ ├── ICacheManagerConfiguration.cs
│ │ ├── ICacheManager.cs
│ │ ├── Internal
│ │ │ ├── BackplaneMessage.cs
│ │ │ ├── BaseCache.cs
│ │ │ ├── BaseCacheHandle.cs
│ │ │ ├── BinaryCacheSerializer.cs
│ │ │ ├── CacheBackplane.cs
│ │ │ ├── CacheEventArgs.cs
│ │ │ ├── CachePerformanceCounters.cs
│ │ │ ├── CachePerformanceCounterType.cs
│ │ │ ├── CacheReflectionHelper.cs
│ │ │ ├── CacheSerializer.cs
│ │ │ ├── CacheStatsCounter.cs
│ │ │ ├── CacheStatsCounterType.cs
│ │ │ ├── CacheStats.cs
│ │ │ ├── DictionaryCacheHandle.cs
│ │ │ ├── ICacheItemProperties.cs
│ │ │ ├── ICacheSerializer.cs
│ │ │ ├── RequiresSerializerAttribute.cs
│ │ │ ├── SerializerCacheItem.cs
│ │ │ ├── TypeCache.cs
│ │ │ └── UpdateItemResult.cs
│ │ ├── Logging
│ │ │ ├── ILogger.cs
│ │ │ ├── ILoggerFactory.cs
│ │ │ ├── LoggerExtensions.cs
│ │ │ └── LogLevel.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── Utility
│ │ ├── Clock.cs
│ │ ├── Guard.cs
│ │ └── ObjectPool.cs
│ ├── CacheManager.Couchbase
│ │ ├── BucketCacheHandle.cs
│ │ ├── CacheManager.Couchbase.csproj
│ │ ├── CouchbaseConfigurationBuilderExtensions.cs
│ │ └── CouchbaseConfigurationManager.cs
│ ├── CacheManager.Memcached
│ │ ├── CacheManager.Memcached.csproj
│ │ ├── MemcachedCacheHandle.cs
│ │ ├── MemcachedConfigurationBuilderExtensions.cs
│ │ └── StatusCode.cs
│ ├── CacheManager.Microsoft.Extensions.Caching.Memory
│ │ ├── CacheManager.Microsoft.Extensions.Caching.Memory.csproj
│ │ ├── MemoryCacheExtensions.cs
│ │ ├── MemoryCacheHandle`1.cs
│ │ ├── MicrosoftMemoryCachingBuilderExtensions.cs
│ │ └── Properties
│ │ └── AssemblyInfo.cs
│ ├── CacheManager.Microsoft.Extensions.Configuration
│ │ ├── CacheManager.Microsoft.Extensions.Configuration.csproj
│ │ ├── MicrosoftConfigurationExtensions.cs
│ │ └── ServiceCollectionExtensions.cs
│ ├── CacheManager.Microsoft.Extensions.Logging
│ │ ├── CacheManager.Microsoft.Extensions.Logging.csproj
│ │ ├── MicrosoftLoggerFactory.cs
│ │ └── MicrosoftLoggingBuilderExtensions.cs
│ ├── CacheManager.Serialization.Bond
│ │ ├── BondCacheItem.cs
│ │ ├── BondCompactBinaryCacheSerializer.cs
│ │ ├── BondConfigurationBuilderExtensions.cs
│ │ ├── BondFastBinaryCacheSerializer.cs
│ │ ├── BondSerializerBase.cs
│ │ ├── BondSimpleJsonCacheSerializer.cs
│ │ ├── CacheManager.Serialization.Bond.csproj
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── SerializerCache.cs
│ ├── CacheManager.Serialization.DataContract
│ │ ├── CacheManager.Serialization.DataContract.csproj
│ │ ├── DataContractBinaryCacheSerializer.cs
│ │ ├── DataContractCacheItem.cs
│ │ ├── DataContractCacheSerializerBase.cs
│ │ ├── DataContractCacheSerializer.cs
│ │ ├── DataContractConfigurationBuilderExtensions.cs
│ │ ├── DataContractGzJsonCacheSerializer.cs
│ │ ├── DataContractJsonCacheSerializer.cs
│ │ └── Properties
│ │ └── AssemblyInfo.cs
│ ├── CacheManager.Serialization.Json
│ │ ├── CacheManager.Serialization.Json.csproj
│ │ ├── GzJsonCacheSerializer.cs
│ │ ├── JsonCacheItem.cs
│ │ ├── JsonCacheSerializer.cs
│ │ ├── JsonConfigurationBuilderExtensions.cs
│ │ └── Properties
│ │ └── AssemblyInfo.cs
│ ├── CacheManager.Serialization.ProtoBuf
│ │ ├── CacheManager.Serialization.ProtoBuf.csproj
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── ProtoBufCacheItem.cs
│ │ ├── ProtoBufConfigurationBuilderExtensions.cs
│ │ └── ProtoBufSerializer.cs
│ ├── CacheManager.StackExchange.Redis
│ │ ├── CacheManager.StackExchange.Redis.csproj
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── RedisCacheBackplane.cs
│ │ ├── RedisCacheHandle.cs
│ │ ├── RedisConfigurationBuilder.cs
│ │ ├── RedisConfigurationBuilderExtensions.cs
│ │ ├── RedisConfiguration.cs
│ │ ├── RedisConfigurations.cs
│ │ ├── RedisConfigurationSection.cs
│ │ ├── RedisConnectionManager.cs
│ │ ├── RedisValueConverter.cs
│ │ ├── RetryHelper.cs
│ │ └── ScriptType.cs
│ ├── CacheManager.SystemRuntimeCaching
│ │ ├── CacheManager.SystemRuntimeCaching.csproj
│ │ ├── MemoryCacheHandle`1.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── RuntimeCachingBuilderExtensions.cs
│ │ └── RuntimeMemoryCacheOptions.cs
│ └── CacheManager.Web
│ ├── CacheManagerOutputCacheProvider.cs
│ ├── CacheManager.Web.csproj
│ ├── ContextFactory.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── SystemWebCacheHandle`1.cs
│ └── WebConfigurationBuilderExtensions.cs
├── test
│ ├── CacheManager.Benchmarks
│ │ ├── BackplaneMessageBenchmark.cs
│ │ ├── BaseCacheManagerBenchmark.cs
│ │ ├── BenchmarkDotNet.Artifacts
│ │ │ ├── results
│ │ │ │ ├── AddSingleBenchmark-report.csv
│ │ │ │ ├── AddSingleBenchmark-report-github.md
│ │ │ │ ├── AddSingleBenchmark-report.html
│ │ │ │ ├── BackplaneMessageBenchmarkMultiple-report.csv
│ │ │ │ ├── BackplaneMessageBenchmarkMultiple-report-github.md
│ │ │ │ ├── BackplaneMessageBenchmarkMultiple-report.html
│ │ │ │ ├── BackplaneMessageBenchmark-report.csv
│ │ │ │ ├── BackplaneMessageBenchmark-report-github.md
│ │ │ │ ├── BackplaneMessageBenchmark-report.html
│ │ │ │ ├── GetSingleBenchmark-report.csv
│ │ │ │ ├── GetSingleBenchmark-report-github.md
│ │ │ │ ├── GetSingleBenchmark-report.html
│ │ │ │ ├── GzBenchmark-report.csv
│ │ │ │ ├── GzBenchmark-report-github.md
│ │ │ │ ├── GzBenchmark-report.html
│ │ │ │ ├── SerializationBenchmark-report.csv
│ │ │ │ ├── SerializationBenchmark-report-github.md
│ │ │ │ ├── SerializationBenchmark-report.html
│ │ │ │ ├── UnixTimestampBenchmark-report.csv
│ │ │ │ ├── UnixTimestampBenchmark-report-github.md
│ │ │ │ └── UnixTimestampBenchmark-report.html
│ │ │ └── results-0.9.3
│ │ │ ├── AddSingleBenchmark-report.csv
│ │ │ ├── AddSingleBenchmark-report-github.md
│ │ │ ├── AddSingleBenchmark-report.html
│ │ │ ├── GetSingleBenchmark-report.csv
│ │ │ ├── GetSingleBenchmark-report-github.md
│ │ │ ├── GetSingleBenchmark-report.html
│ │ │ ├── PutSingleBenchmark-report.csv
│ │ │ ├── PutSingleBenchmark-report-github.md
│ │ │ ├── PutSingleBenchmark-report.html
│ │ │ ├── SerializationBenchmark-report.csv
│ │ │ ├── SerializationBenchmark-report-github.md
│ │ │ ├── SerializationBenchmark-report.html
│ │ │ ├── UpdateSingleBenchmark-report.csv
│ │ │ ├── UpdateSingleBenchmark-report-github.md
│ │ │ └── UpdateSingleBenchmark-report.html
│ │ ├── CacheManager.Benchmarks.csproj
│ │ ├── GzBenchmark.cs
│ │ ├── PlainDictionaryUpdateBenchmark.cs
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── SerializationBenchmark.cs
│ │ ├── TestPoco.cs
│ │ └── UnixTimestampBenchmark.cs
│ ├── CacheManager.Config.Tests
│ │ ├── cache.json
│ │ ├── CacheManager.Config.Tests.csproj
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ ├── Settings.StyleCop
│ │ └── Tests.cs
│ ├── CacheManager.Events.Tests
│ │ ├── CacheEvent.cs
│ │ ├── CacheManager.Events.Tests.csproj
│ │ ├── EventCommand.cs
│ │ ├── EventHandling.cs
│ │ ├── MemoryOnlyCommand.cs
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ ├── RedisAndMemoryCommand.cs
│ │ └── Spinner.cs
│ ├── CacheManager.MSConfiguration.TypeLoad.Tests
│ │ ├── CacheManager.MSConfiguration.TypeLoad.Tests.csproj
│ │ ├── MicrosoftConfigurationTests.cs
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ └── xunit.runner.json
│ └── CacheManager.Tests
│ ├── app.config
│ ├── App.netstandard2.config
│ ├── BackplaneMessageTest.cs
│ ├── CacheFactoryTests.cs
│ ├── CacheItemValidation.cs
│ ├── CacheManagerAdvancedUpdateTests.cs
│ ├── CacheManagerEventsTest.cs
│ ├── CacheManagerExpirationTest.cs
│ ├── CacheManagerRegionTests.cs
│ ├── CacheManagerSimpleTests.cs
│ ├── CacheManagerStatsTest.cs
│ ├── CacheManager.Tests.csproj
│ ├── Configuration
│ │ ├── configuration.ExpireTest.config
│ │ ├── configuration.invalid.backplaneNameNoType.config
│ │ ├── configuration.invalid.backplaneTypeNoName.config
│ │ ├── configuration.invalid.emptyHandleDefinition.config
│ │ ├── configuration.invalid.ExpirationWithoutTimeout.config
│ │ ├── configuration.invalid.invalidDefExpMode.config
│ │ ├── configuration.invalid.invalidDefTimeout.config
│ │ ├── configuration.invalid.InvalidEnablePerfCounters.config
│ │ ├── configuration.invalid.InvalidEnableStats.config
│ │ ├── configuration.invalid.InvalidExpMode.config
│ │ ├── configuration.invalid.InvalidRef.config
│ │ ├── configuration.invalid.InvalidTimeout.config
│ │ ├── configuration.invalid.invalidType.config
│ │ ├── configuration.invalid.InvalidUpdateMode.config
│ │ ├── configuration.invalid.managerWithoutHandles.config
│ │ ├── configuration.invalid.MaxRetries.config
│ │ ├── configuration.invalid.missingDefId.config
│ │ ├── configuration.invalid.missingName.config
│ │ ├── configuration.invalid.missingType.config
│ │ ├── configuration.invalid.noSection.config
│ │ ├── configuration.invalid.RetryTimeout.config
│ │ ├── configuration.invalid.serializerType.config
│ │ └── configuration.valid.allFeatures.config
│ ├── ExcludeFromCodeCoverageAttribute.cs
│ ├── InvalidConfigurationValidationTests.cs
│ ├── LoggingTests.cs
│ ├── MemcachedTests.cs
│ ├── MemoryCacheTests.cs
│ ├── MicrosoftConfigurationTests.cs
│ ├── MicrosoftLoggingTests.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── RedisTests.cs
│ ├── ReplaceCultureAttribute.cs
│ ├── SerializerTests.cs
│ ├── SystemWebCacheHandleWrapper.cs
│ ├── TestCacheManagers.cs
│ ├── TestConfigurationHelper.cs
│ ├── TestHelper.cs
│ ├── TestModel.cs
│ ├── ThreadRandomReadWriteTestBase.cs
│ ├── ThreadTestHelper.cs
│ ├── ValidConfigurationValidationTests.cs
│ └── xunit.runner.json
└── tools
├── CacheManagerCfg.xsd
├── cacheManager.json
├── clear_packages.cmd
├── CodeAnalysis.ruleset
├── common.props
├── key.snk
├── memcached-amd64
│ ├── RunMemcachd.bat
│ ├── run_memcached.sh
│ ├── StopMemcached.bat
│ └── stop_memcached.sh
├── redis
│ ├── Cluster
│ │ ├── 7000
│ │ │ ├── nodes.conf
│ │ │ └── redis.conf
│ │ ├── 7001
│ │ │ ├── nodes.conf
│ │ │ └── redis.conf
│ │ ├── 7002
│ │ │ ├── nodes.conf
│ │ │ └── redis.conf
│ │ ├── 7003
│ │ │ ├── nodes.conf
│ │ │ └── redis.conf
│ │ ├── 7004
│ │ │ ├── nodes.conf
│ │ │ └── redis.conf
│ │ └── 7005
│ │ ├── nodes.conf
│ │ └── redis.conf
│ ├── install.cmd
│ ├── install-service.cmd
│ ├── master.conf
│ ├── master-debug.conf
│ ├── redis-cli master.cmd
│ ├── redis-server cluster.cmd
│ ├── redis-server-full.cmd
│ ├── redis-server-master.cmd
│ ├── redis-server-master-debug.cmd
│ ├── redis-server-sentinel.cmd
│ ├── redis-server-slave.cmd
│ ├── sentinel1.conf
│ ├── sentinel2.conf
│ ├── sentinel3.conf
│ └── slave.conf
├── RedisCfg.xsd
└── version.props
73 directories, 335 files
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论