{"id":3988,"date":"2017-09-06T12:46:33","date_gmt":"2017-09-06T19:46:33","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=3988"},"modified":"2025-06-13T19:40:27","modified_gmt":"2025-06-14T02:40:27","slug":"distributed-caching-aspnet-couchbase","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/","title":{"rendered":"Distributed caching with ASP.NET Core and Couchbase"},"content":{"rendered":"<div class=\"paragraph\">\n<p>Distributed caching can help to improve performance of an ASP.NET Core application. This is especially true for an ASP.NET application that\u2019s deployed to a server farm or scalable cloud environment. Using Couchbase Server for caching is one of the many features that make it an ideal choice for your <a href=\"https:\/\/info.couchbase.com\/engagement_database_white_paper.html\">engagement database needs<\/a>.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>In this blog post, I\u2019ll show you how to use the <a href=\"https:\/\/www.nuget.org\/packages\/Couchbase.Extensions.Caching\">Couchbase.Extensions.Caching middleware plugin<\/a> to easily add distributed caching capabilities to your application.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>You can follow along with the <a href=\"https:\/\/github.com\/couchbaselabs\/blog-source-code\/tree\/master\/Groves\/077AspNetCoreCaching\/CouchbaseAspNetCaching\">sample code I wrote for this post on GitHub<\/a>.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p><em>Please note that Couchbase.Extensions.Caching is currently in a beta2 release (as I\u2019m writing this blog post), so some things may change.<\/em><\/p>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_basic_setup_of_couchbase\">Basic setup of Couchbase<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>First, you\u2019ll need a Couchbase Server cluster running (you can install it <a href=\"https:\/\/developer.couchbase.com\/documentation\/server\/5.0\/install\/install-intro.html\">on-premise<\/a>, or <a href=\"https:\/\/developer.couchbase.com\/documentation\/server\/current\/getting-started\/do-a-quick-install.html\">with Docker<\/a>, or even <a href=\"https:\/\/azuremarketplace.microsoft.com\/en-us\/marketplace\/apps\/couchbase.couchbase-enterprise\">in Azure<\/a> if you\u2019d like).<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>Next, you\u2019ll need to <a href=\"https:\/\/developer.couchbase.com\/documentation\/server\/current\/clustersetup\/create-bucket.html\">create a bucket<\/a> in Couchbase where cached data will be stored. I called mine &#8220;cachebucket&#8221;. You may want to take advantage of the new <a href=\"https:\/\/developer.couchbase.com\/documentation\/server\/5.0\/architecture\/core-data-access-buckets.html#concept_qqk_4r2_xs\">ephemeral bucket feature<\/a> in Couchbase Server 5.0 for caching, but it is not required.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>If you are using Couchbase Server 5.0, you\u2019ll also need to create a user with permissions (Data Writer and Data Reader) on that bucket. To keep things simple, create a user that has the same name as the bucket (e.g. &#8220;cachebucket&#8221;).<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_distributed_caching_with_couchbase_extensions\">Distributed Caching with Couchbase.Extensions<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>The <a href=\"https:\/\/github.com\/couchbaselabs\/Couchbase.Extensions\">Couchbase.Extensions (GitHub)<\/a> project aims to make working with Couchbase Server and .NET Core simpler. Caching is just one of these extensions.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>You can add it to your ASP.NET Core project with NuGet, via Package Manager: <code>Install-Package Couchbase.Extensions.Caching -Version 1.0.0-beta2<\/code>, or with the NuGet UI, or you can use the .NET command line: <code>dotnet add package Couchbase.Extensions.Caching --version 1.0.0-beta2<\/code>.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p><span class=\"image\"><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2017\/09\/07701-nuget-couchbase-distributed-caching-extension.png\" alt=\"Couchbase extension for distributed caching available on NuGet\" \/><\/span><\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>Once you\u2019ve added this to your project, you\u2019ll need to make a couple minor changes to your <code>Startup<\/code> class in <code>Startup.cs<\/code>.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>First, in <code>ConfigureServices<\/code>, add a couple namespaces:<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight decode:true\"><code class=\"language-C#\">using Couchbase.Extensions.Caching;\r\nusing Couchbase.Extensions.DependencyInjection;<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>This will make the Caching namespace available, and specifically the <code>AddDistributedCouchbaseCache<\/code> extension method for <code>IServiceCollection<\/code>. Next, call that extension method from within the <code>ConfigureServices<\/code> method.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>The other namespace in there, <code>DependencyInjection<\/code>, is necessary to inject Couchbase functionality. In this case, it\u2019s going to be used only by the Caching extension. But you can use it for other purposes too, which I will cover in a future blog post.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>But for now, it\u2019s just needed for the <code>AddCouchbase<\/code> extension method on <code>IServiceCollection<\/code>.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>Finally, put them both together, and your <code>ConfigureServices<\/code> method should look like this:<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight decode:true\"><code class=\"language-C#\">public void ConfigureServices(IServiceCollection services)\r\n{\r\n    services.AddMvc();\r\n\r\n    services.AddCouchbase(opt =&gt;\r\n    {\r\n        opt.Servers = new List&lt;Uri&gt;\r\n        {\r\n            new Uri(\"https:\/\/localhost:8091\")\r\n        };\r\n    });\r\n\r\n    services.AddDistributedCouchbaseCache(\"cachebucket\", \"password\", opt =&gt; { });\r\n}<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_using_distributed_caching\">Using distributed caching<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>Now that you have distributed caching setup with Couchbase in your ASP.NET Core project, you can use <code>IDistributedCache<\/code> elsewhere in your project.<\/p>\n<\/div>\n<div class=\"sect2\">\n<h3 id=\"_injecting_idistributedcache\">Injecting IDistributedCache<\/h3>\n<div class=\"paragraph\">\n<p>A simple example would be to use it directly in a controller. It can be injected into constructors as you need it:<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight decode:true\"><code class=\"language-C#\">public class HomeController : Controller\r\n{\r\n    private readonly IDistributedCache _cache;\r\n\r\n    public HomeController(IDistributedCache cache)\r\n    {\r\n        _cache = cache;\r\n    }\r\n\r\n    \/\/ ... snip ...\r\n\r\n}<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect2\">\n<h3 id=\"_caching_strings\">Caching strings<\/h3>\n<div class=\"paragraph\">\n<p>You can use the <code>GetString<\/code> and <code>SetString<\/code> methods to retrieve\/set a string value in the cache.<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight decode:true\"><code class=\"language-C#\">\/\/ cache\/retrieve from cache\r\n\/\/ a string, stored under key \"CachedString1\"\r\nvar message = _cache.GetString(\"CachedString1\");\r\nif (message == null)\r\n{\r\n    message = DateTime.Now + \" \" + Path.GetRandomFileName();\r\n    _cache.SetString(\"CachedString1\", message);\r\n}\r\nViewData[\"Message\"] = \"'CachedString1' is '\" + message + \"'\";<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>This would appear in the &#8220;cachebucket&#8221; bucket as an encoded binary value (not JSON).<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p><span class=\"image\"><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2017\/09\/07702-binary-value-cached.png\" alt=\"String cached in Couchbase\" \/><\/span><\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>In the sample code, I simply print out the <code>ViewData[\"Message\"]<\/code> in the Razor view. It should look something like this:<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p><span class=\"image\"><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2017\/09\/07703-cached-string-output.png\" alt=\"Cached string output to Razor\" \/><\/span><\/p>\n<\/div>\n<\/div>\n<div class=\"sect2\">\n<h3 id=\"_caching_objects\">Caching objects<\/h3>\n<div class=\"paragraph\">\n<p>You can also use <code>Set&lt;&gt;<\/code> and <code>Get&lt;&gt;<\/code> methods to save and retrieve objects in the cache. I created a very simple POCO (Plain Old CLR Object) to demonstrate:<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight decode:true\"><code class=\"language-C#\">public class MyPoco\r\n{\r\n    public string Name { get; set; }\r\n    public int ShoeSize { get; set; }\r\n    public decimal Price { get; set; }\r\n}<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>Next, in the sample, I generate a random string to use as a cache key, and a random generated instance of <code>MyPoco<\/code>. First, I store them in the cache using the <code>Set&lt;&gt;<\/code> method:<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight decode:true\"><code class=\"language-C#\">var pocoKey = Path.GetRandomFileName();\r\n_cache.Set(pocoKey, MyPoco.Generate(), null);\r\nViewData[\"Message2\"] = \"Cached a POCO in '\" + pocoKey + \"'\";<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>Then, I print out the key to the Razor view:<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p><span class=\"image\"><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2017\/09\/07704-cached-poco.png\" alt=\"Cached POCO output to Razor\" \/><\/span><\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>Next, I can use this key to look up the value in Couchbase:<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p><span class=\"image\"><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2017\/09\/07705-cached-poco-couchbase-json.png\" alt=\"Cached POCO in Couchbase\" \/><\/span><\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>Also, notice that it\u2019s been serialized to JSON. This not only means that you can read it, but you can also query it with N1QL (if you need to).<\/p>\n<\/div>\n<\/div>\n<div class=\"sect2\">\n<h3 id=\"_distributed_caching_with_expiration\">Distributed caching with expiration<\/h3>\n<div class=\"paragraph\">\n<p>If you want the values in the cache to expire after a certain period of time, you can specify that with <code>DistributedCacheEntryOptions<\/code> (only <code>SlidingExpiration<\/code> is supported at this time).<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight decode:true\"><code class=\"language-C#\">var anotherPocoKey = Path.GetRandomFileName();\r\n_cache.Set(anotherPocoKey, MyPoco.Generate(), new DistributedCacheEntryOptions\r\n{\r\n    SlidingExpiration = new TimeSpan(0, 0, 10) \/\/ 10 seconds\r\n});\r\nViewData[\"Message3\"] = \"Cached a POCO in '\" + anotherPocoKey + \"'\";<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>In the sample project, I\u2019ve also set this to print out to Razor.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p><span class=\"image\"><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2017\/09\/07706-cached-value-expiration.png\" alt=\"Cached POCO with expiration\" \/><\/span><\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>If you view that document (before the 10 seconds runs out) in Couchbase Console, you\u2019ll see that it has an <code>expiration<\/code> value in its metadata. Here\u2019s an example:<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight decode:true\"><code class=\"language-javascript\">{\r\n  \"id\": \"xjkmswko.v35\",\r\n  \"rev\": \"1-14e1d9998125000059b0404502000001\",\r\n  \"expiration\": 1504723013,\r\n  \"flags\": 33554433\r\n}<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>After 10 seconds, that document will be gone from the bucket, and you\u2019ll see an error &#8220;not found (Document does not exist)&#8221;.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_tearing_down_distributed_caching\">Tearing down distributed caching<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>Finally, don\u2019t forget to cleanup the resources used by the Couchbase .NET SDK for distributed caching. One easy way to do this is with the <code>ApplicationStopped<\/code> event. You can wire this up in <code>Startup<\/code>:<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight decode:true\"><code class=\"language-C#\">appLifetime.ApplicationStopped.Register(() =&gt;\r\n{\r\n    app.ApplicationServices.GetRequiredService&lt;ICouchbaseLifetimeService&gt;().Close();\r\n});<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p><em>Note that you will have to add <code>IApplicationLifetime appLifetime<\/code> as a parameter to the <code>Configure<\/code> method in <code>Startup<\/code> if you haven\u2019t already.<\/em><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_summary\">Summary<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>Using Couchbase Server for distributed caching in your ASP.NET Core application is a great way to improve performance and scalability in your application. These kind of &#8220;engagement&#8221; use cases are what Couchbase Server excels at. To see customers that are using Couchbase Server for caching, check out the <a href=\"https:\/\/www.couchbase.com\/customers\/\">Couchbase Customers<\/a> page.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>If you have questions or comments about the Couchbase.Extensions.Caching project, make sure to check out the <a href=\"https:\/\/github.com\/couchbaselabs\/Couchbase.Extensions\/blob\/master\/docs\/caching.md\">GitHub repository<\/a> or the <a href=\"https:\/\/www.couchbase.com\/forums\/c\/net-sdk\/6\/\">Couchbase .NET SDK forums<\/a>.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>As always, you can reach me by leaving a comment below or finding me on <a href=\"https:\/\/twitter.com\/mgroves\">Twitter @mgroves<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Distributed caching can help to improve performance of an ASP.NET Core application. This is especially true for an ASP.NET application that\u2019s deployed to a server farm or scalable cloud environment. Using Couchbase Server for caching is one of the many [&hellip;]<\/p>\n","protected":false},"author":71,"featured_media":3995,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1811,10126,1816],"tags":[1511,1239,2052],"ppma_author":[8937],"class_list":["post-3988","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet","category-asp-dotnet","category-couchbase-server","tag-cache","tag-caching","tag-extensions"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.7.1 (Yoast SEO v25.7) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Distributed caching with ASP.NET Core and Couchbase - The Couchbase Blog<\/title>\n<meta name=\"description\" content=\"Distributed caching can provide performance and scalability benefits to your ASP.NET Core application. It&#039;s easy with Couchbase Server.\" \/>\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\/distributed-caching-aspnet-couchbase\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Distributed caching with ASP.NET Core and Couchbase\" \/>\n<meta property=\"og:description\" content=\"Distributed caching can provide performance and scalability benefits to your ASP.NET Core application. It&#039;s easy with Couchbase Server.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2017-09-06T19:46:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T02:40:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/077-hero-cache-chips.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1280\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\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=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/\"},\"author\":{\"name\":\"Matthew Groves\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/3929663e372020321b0152dc4fa65a58\"},\"headline\":\"Distributed caching with ASP.NET Core and Couchbase\",\"datePublished\":\"2017-09-06T19:46:33+00:00\",\"dateModified\":\"2025-06-14T02:40:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/\"},\"wordCount\":872,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/077-hero-cache-chips.jpg\",\"keywords\":[\"Cache\",\"caching\",\"extensions\"],\"articleSection\":[\".NET\",\"ASP.NET\",\"Couchbase Server\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/\",\"name\":\"Distributed caching with ASP.NET Core and Couchbase - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/077-hero-cache-chips.jpg\",\"datePublished\":\"2017-09-06T19:46:33+00:00\",\"dateModified\":\"2025-06-14T02:40:27+00:00\",\"description\":\"Distributed caching can provide performance and scalability benefits to your ASP.NET Core application. It's easy with Couchbase Server.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/077-hero-cache-chips.jpg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/077-hero-cache-chips.jpg\",\"width\":1920,\"height\":1280,\"caption\":\"Cache memory chips\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Distributed caching with ASP.NET Core and Couchbase\"}]},{\"@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":"Distributed caching with ASP.NET Core and Couchbase - The Couchbase Blog","description":"Distributed caching can provide performance and scalability benefits to your ASP.NET Core application. It's easy with Couchbase Server.","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\/distributed-caching-aspnet-couchbase\/","og_locale":"en_US","og_type":"article","og_title":"Distributed caching with ASP.NET Core and Couchbase","og_description":"Distributed caching can provide performance and scalability benefits to your ASP.NET Core application. It's easy with Couchbase Server.","og_url":"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/","og_site_name":"The Couchbase Blog","article_published_time":"2017-09-06T19:46:33+00:00","article_modified_time":"2025-06-14T02:40:27+00:00","og_image":[{"width":1920,"height":1280,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/077-hero-cache-chips.jpg","type":"image\/jpeg"}],"author":"Matthew Groves","twitter_card":"summary_large_image","twitter_creator":"@mgroves","twitter_misc":{"Written by":"Matthew Groves","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/"},"author":{"name":"Matthew Groves","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/3929663e372020321b0152dc4fa65a58"},"headline":"Distributed caching with ASP.NET Core and Couchbase","datePublished":"2017-09-06T19:46:33+00:00","dateModified":"2025-06-14T02:40:27+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/"},"wordCount":872,"commentCount":3,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/077-hero-cache-chips.jpg","keywords":["Cache","caching","extensions"],"articleSection":[".NET","ASP.NET","Couchbase Server"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/","url":"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/","name":"Distributed caching with ASP.NET Core and Couchbase - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/077-hero-cache-chips.jpg","datePublished":"2017-09-06T19:46:33+00:00","dateModified":"2025-06-14T02:40:27+00:00","description":"Distributed caching can provide performance and scalability benefits to your ASP.NET Core application. It's easy with Couchbase Server.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/077-hero-cache-chips.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/077-hero-cache-chips.jpg","width":1920,"height":1280,"caption":"Cache memory chips"},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Distributed caching with ASP.NET Core and Couchbase"}]},{"@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\/3988","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=3988"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/3988\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/3995"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=3988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=3988"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=3988"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=3988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}