{"id":2451,"date":"2023-04-11T12:39:02","date_gmt":"2023-04-11T19:39:02","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/"},"modified":"2023-04-11T12:39:02","modified_gmt":"2023-04-11T19:39:02","slug":"extending-dotnet-caching-provider-collections","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/","title":{"rendered":"Extending .NET Caching Provider for Collections"},"content":{"rendered":"\n<p><span>To help .NET developers better use Couchbase in their applications, there is a collection of community-supported <\/span><a href=\"https:\/\/github.com\/couchbaselabs\/Couchbase.Extensions\" target=\"_blank\" rel=\"noopener\"><span>Couchbase Extensions<\/span><\/a><span>. These include extensions for caching, session, multiop, compression, and locking. And there are some officially supported extensions for <a href=\"https:\/\/www.couchbase.com\/blog\/dependency-injection-aspnet-couchbase\/\">dependency injection<\/a>, open telemetry, and transactions.<\/span><\/p>\n\n\n\n<p><span>The main extension for discussion today is <\/span><b>Couchbase.Extensions.Caching<\/b><span>, which implements the <\/span><a href=\"https:\/\/learn.microsoft.com\/en-us\/aspnet\/core\/performance\/caching\/distributed?view=aspnetcore-7.0\" target=\"_blank\" rel=\"noopener\"><span>.NET Distributed Cache interface<\/span><\/a><span> using Couchbase. This can be added to your project with <\/span><a href=\"https:\/\/www.nuget.org\/packages\/Couchbase.Extensions.Caching\" target=\"_blank\" rel=\"noopener\"><span>NuGet<\/span><\/a><span> (<\/span><em><span>dotnet add package Couchbase.Extensions.Caching<\/span><\/em><span>).<\/span><\/p>\n\n\n\n<p><span>Recently, I was working with a customer in the cruise industry that is managing several applications, and wants to store caching data separately for each application. However, creating an entirely new bucket for each application is overkill. They were wondering how to specify a scope\/collection when using the <em>Couchbase.Extensions.Caching<\/em> library.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Session and Caching Extensions<\/h2>\n\n\n\n<p><span>In recent years, the shift from Couchbase SDK 2 to SDK 3 introduced many new features and improvements, including <\/span><a href=\"https:\/\/www.couchbase.com\/blog\/couchbase-server-7-0-release\/\" target=\"_blank\" rel=\"noopener\"><span>scopes\/collections support<\/span><\/a><span>. The <em>Couchbase.Extensions<\/em> family has also been updated to support SDK 3.<\/span><\/p>\n\n\n\n<p><span>However, the <\/span><b>default<\/b><span> usage of this library uses the <\/span><em><span>_default<\/span><\/em><span> scope and <\/span><em><span>_default<\/span><\/em><span> collection, with no built-in option to specify anything else.<\/span><\/p>\n\n\n\n<p><span>To see this in action, here\u2019s the line of configuration to add Couchbase as a distributed cache (taken from the <\/span><a href=\"https:\/\/github.com\/couchbaselabs\/Couchbase.Extensions\/tree\/master\/example\/Couchbase.Extensions.Caching.Example\" target=\"_blank\" rel=\"noopener\"><span>GitHub example project<\/span><\/a><span>):<\/span><\/p>\n\n\n<p>[crayon nums=&#8221;false&#8221; lang=&#8221;c#&#8221; decode=&#8221;true&#8221;]builder.Services.AddDistributedCouchbaseCache(&#8220;myproject&#8221;, opt =&gt; { });[\/crayon]<\/p>\n\n\n\n<p><span>In that code, <em>myproject<\/em>\u00a0is a bucket name. The <\/span><em><span>opt<\/span><\/em><span> object doesn\u2019t have an option for scope\/collection name.<\/span><\/p>\n\n\n\n<p><span>Using the sample project, you\u2019ll end up with cached information like this:<\/span><\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14284\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/extending-asp-net-caching-couchbase1.png\" alt=\"\" width=\"722\" height=\"246\"><\/p>\n\n\n\n<p><span>(Notice the bucket, scope, and collection names are <em>myproject<\/em>, <em>_default<\/em>, and <em>_default<\/em>).<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Extending the Extension<\/h2>\n\n\n\n<p><span>Thankfully, the library is extensible enough that with a little bit of code, it can be pointed to whatever collection you\u2019d like.<\/span><\/p>\n\n\n\n<p><span>Let\u2019s look a little deeper at the project, specifically <em>ICouchbaseCacheCollectionProvider.cs<\/em> and <em>DefaultCouchbaseCacheCollectionProvider.cs<\/em><\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><em><span>ICouchbaseCacheCollectionProvider<\/span><\/em><span> contains one method, <\/span><em><span>GetCollectionAsync<\/span><\/em><span>.<\/span><\/li>\n\n\n<li><span><em>DefaultCouchbaseCacheCollectionProvider\u2019s<\/em> implements that method with: <em>return bucket.DefaultCollection();<\/em><\/span><\/li>\n\n<\/ul>\n\n\n\n<p><span>But what if you don\u2019t want to use the default collection?<\/span><\/p>\n\n\n\n<p><span>In that case, create a custom implementation of <\/span><em><span>ICouchbaseCacheCollectionProvider<\/span><\/em><span>. I\u2019ll call mine <\/span><em><span>CustomCouchbaseCacheCollectionProvider<\/span><\/em><span>:<\/span><\/p>\n\n\n<p>[crayon nums=&#8221;false&#8221; lang=&#8221;c#&#8221; decode=&#8221;true&#8221;]using Couchbase.KeyValue;<br \/>\nnamespace Couchbase.Extensions.Caching.Example.Caching;<\/p>\n<p>public class CustomCouchbaseCacheCollectionProvider : ICouchbaseCacheCollectionProvider<br \/>\n{<br \/>\n\u00a0 \u00a0 private readonly ICouchbaseCacheBucketProvider _bucketProvider;<br \/>\n\u00a0 \u00a0 private readonly string _scopeName;<br \/>\n\u00a0 \u00a0 private readonly string _collectionName;<\/p>\n<p>\u00a0 \u00a0 public CustomCouchbaseCacheCollectionProvider(ICouchbaseCacheBucketProvider bucketProvider, string scopeName, string collectionName)<br \/>\n\u00a0 \u00a0 {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 _bucketProvider = bucketProvider;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 _scopeName = scopeName;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 _collectionName = collectionName;<br \/>\n\u00a0 \u00a0 }<\/p>\n<p>\u00a0 \u00a0 public async ValueTask&lt;ICouchbaseCollection&gt; GetCollectionAsync()<br \/>\n\u00a0 \u00a0 {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 var bucket = await _bucketProvider.GetBucketAsync().ConfigureAwait(false);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 var scope = await bucket.ScopeAsync(_scopeName);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 return await scope.CollectionAsync(_collectionName);<br \/>\n\u00a0 \u00a0 }<br \/>\n}[\/crayon]<\/p>\n\n\n\n<p><span>Consider this a starting point. In your implementation, you can set it up however you\u2019d like, add additional logic, etc.<\/span><\/p>\n\n\n\n<p><span>The next step is to add that as a service (in <em>Program.cs<\/em> typically), specifying the scope\/collection names:<\/span><\/p>\n\n\n<p>[crayon nums=&#8221;false&#8221; lang=&#8221;c#&#8221; decode=&#8221;true&#8221;]builder.Services.AddSingleton&lt;ICouchbaseCacheCollectionProvider&gt;(x =&gt;<br \/>\n\u00a0 \u00a0 new CustomCouchbaseCacheCollectionProvider(<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 x.GetRequiredService&lt;ICouchbaseCacheBucketProvider&gt;(),<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &#8220;mycachingscope&#8221;,<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &#8220;mycachingcollection&#8221;));[\/crayon]<\/p>\n\n\n\n<p><span>If you\u2019re concerned about this being overwritten by the default provider, note that <\/span><em><span>TryAddSingleton<\/span><\/em><span> is <a href=\"https:\/\/github.com\/couchbaselabs\/Couchbase.Extensions\/blob\/master\/src\/Couchbase.Extensions.Caching\/CouchbaseCacheServiceCollectionExtensions.cs#L30\" target=\"_blank\" rel=\"noopener\">used inside of<\/a>\u00a0<\/span><em><span>AddDistributedCouchbaseCache<\/span><\/em><span>. This means that it <\/span><b>won\u2019t<\/b><span> override your custom provider with the default provider.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Custom Provider in Action<\/h2>\n\n\n\n<p><span>This extension will not actually create the specified scope and collection, so make sure you\u2019ve created them ahead of time.<\/span><\/p>\n\n\n\n<p><span>Run the app, and try out the Weather Forecast API with the OpenAPI interactive page. The first time executing the endpoint will result in a &#8220;cache miss&#8221;, at which point the weather forecast data will be written to the collection specified:<\/span><\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14285\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/extending-asp-net-caching-with-collections.png\" alt=\"\" width=\"621\" height=\"263\"><\/p>\n\n\n\n<p><span>(Notice the bucket, scope, and collection names are <em>myproject<\/em>, <em>mycachingscope<\/em>, and <em>mycachingcollection<\/em>).<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p><span>With a custom implementation of an interface, and one extra line in <\/span><em><span>Program.cs<\/span><\/em><span>, you can specify whatever scope\/collection you want to store cached data into.<\/span><\/p>\n\n\n\n<p><span>Further, the <\/span><b>Couchbase.Extensions.Session<\/b><span> extension uses the caching extension as the underlying storage mechanism.<\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span>Happy caching! <\/span><a href=\"https:\/\/github.com\/couchbaselabs\/blog-source-code\/tree\/master\/Groves\/142ExtendingAspNetCaching\" target=\"_blank\" rel=\"noopener\"><span>Source code is available in GitHub<\/span><\/a><span>.<\/span><\/li>\n\n\n<li><span>For more on .NET, check out the <\/span><a href=\"https:\/\/www.couchbase.com\/forums\/c\/net-sdk\/6\/\" target=\"_blank\" rel=\"noopener\"><span>Couchbase .NET forum<\/span><\/a><span> and <\/span><a href=\"https:\/\/docs.couchbase.com\/dotnet-sdk\/current\/hello-world\/start-using-sdk.html\" target=\"_blank\" rel=\"noopener\"><span>.NET SDK documentation<\/span><\/a><span>.<\/span><\/li>\n\n\n<li><span>If you\u2019ve got questions on caching, session, or architecture in general, check out the <\/span><a href=\"https:\/\/www.couchbase.com\/developers\/community\/\" target=\"_blank\" rel=\"noopener\"><span>Couchbase Discord<\/span><\/a><span>.<\/span><\/li>\n\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>To help .NET developers better use Couchbase in their applications, there is a collection of community-supported Couchbase Extensions. These include extensions for caching, session, multiop, compression, and locking. And there are some officially supported extensions for dependency injection, open telemetry, and transactions. The main extension for discussion today is Couchbase.Extensions.Caching, which implements the .NET Distributed [&hellip;]<\/p>\n","protected":false},"author":71,"featured_media":2450,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[33,127,17,428,64],"tags":[643,644],"ppma_author":[186],"class_list":["post-2451","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet","category-application-design","category-performance","category-scopes-and-collections","category-tools-sdks","tag-extensions","tag-session"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.6 (Yoast SEO v27.6) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Extending .NET Caching Provider for Collections<\/title>\n<meta name=\"description\" content=\"With a custom implementation of an interface, and one extra line in your code, you can specify custom scope\/collections for storing data.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Extending .NET Caching Provider for Collections\" \/>\n<meta property=\"og:description\" content=\"With a custom implementation of an interface, and one extra line in your code, you can specify custom scope\/collections for storing data.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-04-11T19:39:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/extending-dotnet-provider-collections.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Matthew Groves\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@mgroves\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Matthew Groves\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/extending-dotnet-caching-provider-collections\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/extending-dotnet-caching-provider-collections\\\/\"},\"author\":{\"name\":\"Matthew Groves\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/3929663e372020321b0152dc4fa65a58\"},\"headline\":\"Extending .NET Caching Provider for Collections\",\"datePublished\":\"2023-04-11T19:39:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/extending-dotnet-caching-provider-collections\\\/\"},\"wordCount\":687,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/extending-dotnet-caching-provider-collections\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/extending-dotnet-provider-collections.png\",\"keywords\":[\"extensions\",\"session\"],\"articleSection\":[\".NET\",\"Application Design\",\"High Performance\",\"Scopes and Collections\",\"Tools &amp; SDKs\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/extending-dotnet-caching-provider-collections\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/extending-dotnet-caching-provider-collections\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/extending-dotnet-caching-provider-collections\\\/\",\"name\":\"Extending .NET Caching Provider for Collections\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/extending-dotnet-caching-provider-collections\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/extending-dotnet-caching-provider-collections\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/extending-dotnet-provider-collections.png\",\"datePublished\":\"2023-04-11T19:39:02+00:00\",\"description\":\"With a custom implementation of an interface, and one extra line in your code, you can specify custom scope\\\/collections for storing data.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/extending-dotnet-caching-provider-collections\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/extending-dotnet-caching-provider-collections\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/extending-dotnet-caching-provider-collections\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/extending-dotnet-provider-collections.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/extending-dotnet-provider-collections.png\",\"width\":1200,\"height\":628},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/extending-dotnet-caching-provider-collections\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Extending .NET Caching Provider for Collections\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/06\\\/logo.svg\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/06\\\/logo.svg\",\"width\":\"1024\",\"height\":\"1024\",\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/3929663e372020321b0152dc4fa65a58\",\"name\":\"Matthew Groves\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/70feb1b28a099ad0112b8d21fe1e81e1a4524beed3e20b7f107d5370e85a07ab?s=96&d=mm&r=gba51e6aacc53995c323a634e4502ef54\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/70feb1b28a099ad0112b8d21fe1e81e1a4524beed3e20b7f107d5370e85a07ab?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/70feb1b28a099ad0112b8d21fe1e81e1a4524beed3e20b7f107d5370e85a07ab?s=96&d=mm&r=g\",\"caption\":\"Matthew Groves\"},\"description\":\"Matthew D. Groves is a guy who loves to code. It doesn't matter if it's C#, jQuery, or PHP: he'll submit pull requests for anything. He has been coding professionally ever since he wrote a QuickBASIC point-of-sale app for his parent's pizza shop back in the 90s. He currently works as a Senior Product Marketing Manager for Couchbase. His free time is spent with his family, watching the Reds, and getting involved in the developer community. He is the author of AOP in .NET, Pro Microservices in .NET, a Pluralsight author, and a Microsoft MVP.\",\"sameAs\":[\"https:\\\/\\\/crosscuttingconcerns.com\",\"https:\\\/\\\/x.com\\\/mgroves\"],\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/author\\\/matthew-groves\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Extending .NET Caching Provider for Collections","description":"With a custom implementation of an interface, and one extra line in your code, you can specify custom scope\/collections for storing data.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/","og_locale":"en_US","og_type":"article","og_title":"Extending .NET Caching Provider for Collections","og_description":"With a custom implementation of an interface, and one extra line in your code, you can specify custom scope\/collections for storing data.","og_url":"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/","og_site_name":"The Couchbase Blog","article_published_time":"2023-04-11T19:39:02+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/extending-dotnet-provider-collections.png","type":"image\/png"}],"author":"Matthew Groves","twitter_card":"summary_large_image","twitter_creator":"@mgroves","twitter_misc":{"Written by":"Matthew Groves","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/"},"author":{"name":"Matthew Groves","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/3929663e372020321b0152dc4fa65a58"},"headline":"Extending .NET Caching Provider for Collections","datePublished":"2023-04-11T19:39:02+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/"},"wordCount":687,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/extending-dotnet-provider-collections.png","keywords":["extensions","session"],"articleSection":[".NET","Application Design","High Performance","Scopes and Collections","Tools &amp; SDKs"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/","url":"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/","name":"Extending .NET Caching Provider for Collections","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/extending-dotnet-provider-collections.png","datePublished":"2023-04-11T19:39:02+00:00","description":"With a custom implementation of an interface, and one extra line in your code, you can specify custom scope\/collections for storing data.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/extending-dotnet-provider-collections.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/extending-dotnet-provider-collections.png","width":1200,"height":628},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Extending .NET Caching Provider for Collections"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/06\/logo.svg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/06\/logo.svg","width":"1024","height":"1024","caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/3929663e372020321b0152dc4fa65a58","name":"Matthew Groves","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/70feb1b28a099ad0112b8d21fe1e81e1a4524beed3e20b7f107d5370e85a07ab?s=96&d=mm&r=gba51e6aacc53995c323a634e4502ef54","url":"https:\/\/secure.gravatar.com\/avatar\/70feb1b28a099ad0112b8d21fe1e81e1a4524beed3e20b7f107d5370e85a07ab?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/70feb1b28a099ad0112b8d21fe1e81e1a4524beed3e20b7f107d5370e85a07ab?s=96&d=mm&r=g","caption":"Matthew Groves"},"description":"Matthew D. Groves is a guy who loves to code. It doesn't matter if it's C#, jQuery, or PHP: he'll submit pull requests for anything. He has been coding professionally ever since he wrote a QuickBASIC point-of-sale app for his parent's pizza shop back in the 90s. He currently works as a Senior Product Marketing Manager for Couchbase. His free time is spent with his family, watching the Reds, and getting involved in the developer community. He is the author of AOP in .NET, Pro Microservices in .NET, a Pluralsight author, and a Microsoft MVP.","sameAs":["https:\/\/crosscuttingconcerns.com","https:\/\/x.com\/mgroves"],"url":"https:\/\/www.couchbase.com\/blog\/author\/matthew-groves\/"}]}},"acf":[],"authors":[{"term_id":186,"user_id":71,"is_guest":0,"slug":"matthew-groves","display_name":"Matthew Groves","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/2451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/71"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=2451"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/2451\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/2450"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=2451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=2451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=2451"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=2451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}