![]() |
VOOZH | about |
dotnet add package Couchbase.Extensions.Caching --version 5.0.1
NuGet\Install-Package Couchbase.Extensions.Caching -Version 5.0.1
<PackageReference Include="Couchbase.Extensions.Caching" Version="5.0.1" />
<PackageVersion Include="Couchbase.Extensions.Caching" Version="5.0.1" />Directory.Packages.props
<PackageReference Include="Couchbase.Extensions.Caching" />Project file
paket add Couchbase.Extensions.Caching --version 5.0.1
#r "nuget: Couchbase.Extensions.Caching, 5.0.1"
#:package Couchbase.Extensions.Caching@5.0.1
#addin nuget:?package=Couchbase.Extensions.Caching&version=5.0.1Install as a Cake Addin
#tool nuget:?package=Couchbase.Extensions.Caching&version=5.0.1Install as a Cake Tool
A custom ASP.NET Core Middleware plugin for a distributed cache using Couchbase server as the backing store. Supports both Ephemeral (in-memory) and Couchbase (persistent) buckets.
Assuming you have an installation of Couchbase Server and Visual Studio (examples with VSCODE forthcoming), do the following:
In Setup.cs add the following to the ConfigureServices method:
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
services.AddCouchbase(opt =>
{
opt.ConnectionString = "couchbase://localhost";
opt.UserName = "Administrator";
opt.Password = "password";
});
services.AddDistributedCouchbaseCache(opt => {
opt.BucketName = "cache";
opt.ScopeName = "my_service";
opt.CollectionName = "my_collection";
});
}
You can change the localhost hostname to wherever you are hosting your Couchbase cluster.
In your controller add a parameter for ICouchbaseCache or IDistributedCache to the constructor.
Using IDistributedCache will allow persistence of byte[] to the cache. ICouchbaseCache extends
this functionality with additional methods for storing and retrieving typed objects.
public class HomeController : Controller
{
private ICouchbaseCache _cache;
public HomeController(ICouchbaseCache cache)
{
_cache = cache;
}
public async Task<IActionResult> Index()
{
await _cache.SetAsync("CacheTime", DateTimeOffset.Now);
return View();
}
public IActionResult About()
{
ViewData["Message"] = "Your application description page. "
+ (await _cache.GetAsync<DateTimeOffset>("CacheTime"));
return View();
}
}
For performance reasons, we strongly recommend using the Async overloads and not the synchronous methods on IDistributeCache.
Any type you persist in the cache will be transcoded and serialized using the transcoder and serializer
configured in the call to AddCouchbase. By default, this is the JsonTranscoder and the DefaultSerializer
which uses Newtonsoft.Json. However, setting and getting byte[] is always transcoded as raw binary regardless
of the configured transcoder.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 2 NuGet packages that depend on Couchbase.Extensions.Caching:
| Package | Downloads |
|---|---|
|
Couchbase.Extensions.Session
A custom ASP.NET Core Middleware plugin for distributed session state using Couchbase server as the backing store. Supports both Memcached (in-memory) and Couchbase (persistent) buckets. |
|
|
Couchbase.Aspire.Client.DistributedCaching
A Couchbase implementation for IDistributedCache that integrates with Aspire, including health checks, logging, and telemetry. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 5.0.1 | 5,456 | 3/20/2026 |
| 4.1.0-rc3 | 112 | 2/12/2026 |
| 4.1.0-rc2 | 120 | 2/5/2026 |
| 4.1.0-rc1 | 197 | 12/12/2025 |
| 4.0.1 | 9,169 | 10/22/2025 |
| 4.0.0 | 10,247 | 2/26/2025 |
| 3.3.5 | 188,034 | 9/19/2022 |
| 3.3.4 | 1,717 | 9/14/2022 |
| 3.2.5 | 153,794 | 12/17/2021 |
| 2.0.0-beta.2 | 508 | 9/15/2021 |
| 1.0.2 | 193,711 | 8/11/2018 |
| 1.0.1 | 7,050 | 3/1/2018 |
| 1.0.0 | 4,873 | 11/8/2017 |