{"id":14283,"date":"2023-04-11T12:39:02","date_gmt":"2023-04-11T19:39:02","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=14283"},"modified":"2025-06-13T20:19:09","modified_gmt":"2025-06-14T03:19:09","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":"<p><span style=\"font-weight: 400\">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 style=\"font-weight: 400\">Couchbase Extensions<\/span><\/a><span style=\"font-weight: 400\">. 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<p><span style=\"font-weight: 400\">The main extension for discussion today is <\/span><b>Couchbase.Extensions.Caching<\/b><span style=\"font-weight: 400\">, 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 style=\"font-weight: 400\">.NET Distributed Cache interface<\/span><\/a><span style=\"font-weight: 400\"> 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 style=\"font-weight: 400\">NuGet<\/span><\/a><span style=\"font-weight: 400\"> (<\/span><em><span style=\"font-weight: 400\">dotnet add package Couchbase.Extensions.Caching<\/span><\/em><span style=\"font-weight: 400\">).<\/span><\/p>\n<p><span style=\"font-weight: 400\">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<h2>Session and Caching Extensions<\/h2>\n<p><span style=\"font-weight: 400\">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 style=\"font-weight: 400\">scopes\/collections support<\/span><\/a><span style=\"font-weight: 400\">. The <em>Couchbase.Extensions<\/em> family has also been updated to support SDK 3.<\/span><\/p>\n<p><span style=\"font-weight: 400\">However, the <\/span><b>default<\/b><span style=\"font-weight: 400\"> usage of this library uses the <\/span><em><span style=\"font-weight: 400\">_default<\/span><\/em><span style=\"font-weight: 400\"> scope and <\/span><em><span style=\"font-weight: 400\">_default<\/span><\/em><span style=\"font-weight: 400\"> collection, with no built-in option to specify anything else.<\/span><\/p>\n<p><span style=\"font-weight: 400\">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 style=\"font-weight: 400\">GitHub example project<\/span><\/a><span style=\"font-weight: 400\">):<\/span><\/p>\n<pre class=\"nums:false lang:c# decode:true \">builder.Services.AddDistributedCouchbaseCache(\"myproject\", opt =&gt; { });<\/pre>\n<p><span style=\"font-weight: 400\">In that code, <em>myproject<\/em>\u00a0is a bucket name. The <\/span><em><span style=\"font-weight: 400\">opt<\/span><\/em><span style=\"font-weight: 400\"> object doesn\u2019t have an option for scope\/collection name.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Using the sample project, you\u2019ll end up with cached information like this:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14284\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/extending-asp-net-caching-couchbase1.png\" alt=\"\" width=\"722\" height=\"246\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/04\/extending-asp-net-caching-couchbase1.png 722w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/04\/extending-asp-net-caching-couchbase1-300x102.png 300w\" sizes=\"auto, (max-width: 722px) 100vw, 722px\" \/><\/p>\n<p><span style=\"font-weight: 400\">(Notice the bucket, scope, and collection names are <em>myproject<\/em>, <em>_default<\/em>, and <em>_default<\/em>).<\/span><\/p>\n<h2>Extending the Extension<\/h2>\n<p><span style=\"font-weight: 400\">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<p><span style=\"font-weight: 400\">Let\u2019s look a little deeper at the project, specifically <em>ICouchbaseCacheCollectionProvider.cs<\/em> and <em>DefaultCouchbaseCacheCollectionProvider.cs<\/em><\/span><\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li style=\"font-weight: 400\"><em><span style=\"font-weight: 400\">ICouchbaseCacheCollectionProvider<\/span><\/em><span style=\"font-weight: 400\"> contains one method, <\/span><em><span style=\"font-weight: 400\">GetCollectionAsync<\/span><\/em><span style=\"font-weight: 400\">.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\"><em>DefaultCouchbaseCacheCollectionProvider\u2019s<\/em> implements that method with: <em>return bucket.DefaultCollection();<\/em><\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">But what if you don\u2019t want to use the default collection?<\/span><\/p>\n<p><span style=\"font-weight: 400\">In that case, create a custom implementation of <\/span><em><span style=\"font-weight: 400\">ICouchbaseCacheCollectionProvider<\/span><\/em><span style=\"font-weight: 400\">. I\u2019ll call mine <\/span><em><span style=\"font-weight: 400\">CustomCouchbaseCacheCollectionProvider<\/span><\/em><span style=\"font-weight: 400\">:<\/span><\/p>\n<pre class=\"nums:false lang:c# decode:true \">using Couchbase.KeyValue;\r\nnamespace Couchbase.Extensions.Caching.Example.Caching;\r\n\r\npublic class CustomCouchbaseCacheCollectionProvider : ICouchbaseCacheCollectionProvider\r\n{\r\n\u00a0 \u00a0 private readonly ICouchbaseCacheBucketProvider _bucketProvider;\r\n\u00a0 \u00a0 private readonly string _scopeName;\r\n\u00a0 \u00a0 private readonly string _collectionName;\r\n\r\n\u00a0 \u00a0 public CustomCouchbaseCacheCollectionProvider(ICouchbaseCacheBucketProvider bucketProvider, string scopeName, string collectionName)\r\n\u00a0 \u00a0 {\r\n\u00a0 \u00a0 \u00a0 \u00a0 _bucketProvider = bucketProvider;\r\n\u00a0 \u00a0 \u00a0 \u00a0 _scopeName = scopeName;\r\n\u00a0 \u00a0 \u00a0 \u00a0 _collectionName = collectionName;\r\n\u00a0 \u00a0 }\r\n\r\n\u00a0 \u00a0 public async ValueTask&lt;ICouchbaseCollection&gt; GetCollectionAsync()\r\n\u00a0 \u00a0 {\r\n\u00a0 \u00a0 \u00a0 \u00a0 var bucket = await _bucketProvider.GetBucketAsync().ConfigureAwait(false);\r\n\u00a0 \u00a0 \u00a0 \u00a0 var scope = await bucket.ScopeAsync(_scopeName);\r\n\u00a0 \u00a0 \u00a0 \u00a0 return await scope.CollectionAsync(_collectionName);\r\n\u00a0 \u00a0 }\r\n}<\/pre>\n<p><span style=\"font-weight: 400\">Consider this a starting point. In your implementation, you can set it up however you\u2019d like, add additional logic, etc.<\/span><\/p>\n<p><span style=\"font-weight: 400\">The next step is to add that as a service (in <em>Program.cs<\/em> typically), specifying the scope\/collection names:<\/span><\/p>\n<pre class=\"nums:false lang:c# decode:true \">builder.Services.AddSingleton&lt;ICouchbaseCacheCollectionProvider&gt;(x =&gt;\r\n\u00a0 \u00a0 new CustomCouchbaseCacheCollectionProvider(\r\n\u00a0 \u00a0 \u00a0 \u00a0 x.GetRequiredService&lt;ICouchbaseCacheBucketProvider&gt;(),\r\n\u00a0 \u00a0 \u00a0 \u00a0 \"mycachingscope\",\r\n\u00a0 \u00a0 \u00a0 \u00a0 \"mycachingcollection\"));<\/pre>\n<p><span style=\"font-weight: 400\">If you\u2019re concerned about this being overwritten by the default provider, note that <\/span><em><span style=\"font-weight: 400\">TryAddSingleton<\/span><\/em><span style=\"font-weight: 400\"> 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 style=\"font-weight: 400\">AddDistributedCouchbaseCache<\/span><\/em><span style=\"font-weight: 400\">. This means that it <\/span><b>won\u2019t<\/b><span style=\"font-weight: 400\"> override your custom provider with the default provider.<\/span><\/p>\n<h2>Custom Provider in Action<\/h2>\n<p><span style=\"font-weight: 400\">This extension will not actually create the specified scope and collection, so make sure you\u2019ve created them ahead of time.<\/span><\/p>\n<p><span style=\"font-weight: 400\">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<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14285\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/extending-asp-net-caching-with-collections.png\" alt=\"\" width=\"621\" height=\"263\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/04\/extending-asp-net-caching-with-collections.png 621w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/04\/extending-asp-net-caching-with-collections-300x127.png 300w\" sizes=\"auto, (max-width: 621px) 100vw, 621px\" \/><\/p>\n<p><span style=\"font-weight: 400\">(Notice the bucket, scope, and collection names are <em>myproject<\/em>, <em>mycachingscope<\/em>, and <em>mycachingcollection<\/em>).<\/span><\/p>\n<h2>Summary<\/h2>\n<p><span style=\"font-weight: 400\">With a custom implementation of an interface, and one extra line in <\/span><em><span style=\"font-weight: 400\">Program.cs<\/span><\/em><span style=\"font-weight: 400\">, you can specify whatever scope\/collection you want to store cached data into.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Further, the <\/span><b>Couchbase.Extensions.Session<\/b><span style=\"font-weight: 400\"> extension uses the caching extension as the underlying storage mechanism.<\/span><\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li><span style=\"font-weight: 400\">Happy caching! <\/span><a href=\"https:\/\/github.com\/couchbaselabs\/blog-source-code\/tree\/master\/Groves\/142ExtendingAspNetCaching\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400\">Source code is available in GitHub<\/span><\/a><span style=\"font-weight: 400\">.<\/span><\/li>\n<li><span style=\"font-weight: 400\">For more on .NET, check out the <\/span><a href=\"https:\/\/www.couchbase.com\/forums\/c\/net-sdk\/6\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400\">Couchbase .NET forum<\/span><\/a><span style=\"font-weight: 400\"> and <\/span><a href=\"https:\/\/docs.couchbase.com\/dotnet-sdk\/current\/hello-world\/start-using-sdk.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400\">.NET SDK documentation<\/span><\/a><span style=\"font-weight: 400\">.<\/span><\/li>\n<li><span style=\"font-weight: 400\">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 style=\"font-weight: 400\">Couchbase Discord<\/span><\/a><span style=\"font-weight: 400\">.<\/span><\/li>\n<\/ul>\n<\/li>\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, [&hellip;]<\/p>\n","protected":false},"author":71,"featured_media":14286,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1811,1814,9417,9336,2201],"tags":[2052,2024],"ppma_author":[8937],"class_list":["post-14283","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"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\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=\"article:modified_time\" content=\"2025-06-14T03:19:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/04\/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\",\"dateModified\":\"2025-06-14T03:19:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/\"},\"wordCount\":576,\"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\/1\/2023\/04\/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\/1\/2023\/04\/extending-dotnet-provider-collections.png\",\"datePublished\":\"2023-04-11T19:39:02+00:00\",\"dateModified\":\"2025-06-14T03:19:09+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\/1\/2023\/04\/extending-dotnet-provider-collections.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/04\/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\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"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:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/ba51e6aacc53995c323a634e4502ef54\",\"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","article_modified_time":"2025-06-14T03:19:09+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/04\/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","dateModified":"2025-06-14T03:19:09+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/extending-dotnet-caching-provider-collections\/"},"wordCount":576,"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\/1\/2023\/04\/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\/1\/2023\/04\/extending-dotnet-provider-collections.png","datePublished":"2023-04-11T19:39:02+00:00","dateModified":"2025-06-14T03:19:09+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\/1\/2023\/04\/extending-dotnet-provider-collections.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/04\/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\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"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:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/ba51e6aacc53995c323a634e4502ef54","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\/"}]}},"authors":[{"term_id":8937,"user_id":71,"is_guest":0,"slug":"matthew-groves","display_name":"Matthew Groves","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/70feb1b28a099ad0112b8d21fe1e81e1a4524beed3e20b7f107d5370e85a07ab?s=96&d=mm&r=g","author_category":"","last_name":"Groves","first_name":"Matthew","job_title":"","user_url":"https:\/\/crosscuttingconcerns.com","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."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/14283","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=14283"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/14283\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/14286"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=14283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=14283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=14283"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=14283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}