RickDotNet.Apollo.Caching 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package RickDotNet.Apollo.Caching --version 0.2.0
NuGet\Install-Package RickDotNet.Apollo.Caching -Version 0.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RickDotNet.Apollo.Caching" Version="0.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RickDotNet.Apollo.Caching --version 0.2.0
#r "nuget: RickDotNet.Apollo.Caching, 0.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install RickDotNet.Apollo.Caching as a Cake Addin
#addin nuget:?package=RickDotNet.Apollo.Caching&version=0.2.0

// Install RickDotNet.Apollo.Caching as a Cake Tool
#tool nuget:?package=RickDotNet.Apollo.Caching&version=0.2.0

Apollo.Caching

Apollo.Caching is an extension of the Apollo library that provides a distributed caching solution using NATS as the meat and potatoes. It leverages the high-performance and scalability of NATS to offer a robust caching mechanism suitable for microservices and distributed systems built with .NET.

Features

  • Distributed Caching: Share cache data across multiple instances of your application.
  • NATS Integration: Built directly on top of the NATS messaging system for seamless communication.
  • MessagePack Serialization: Utilizes MessagePack for efficient binary serialization of cache items.
  • Easy Setup: Integrate distributed caching into your Apollo setup with minimal configuration.
  • Expiration Support: Supports absolute and sliding expiration for cache entries.

Getting Started

Before using Apollo.Caching, ensure that you have a running instance of NATS and the Apollo library set up in your project. Follow the instructions in the Apollo README.md to set up Apollo and NATS.

Installation

To add Apollo.Caching to your project, you can install it via NuGet:

Install-Package RickDotNet.Apollo.Caching

Or via the .NET CLI:

dotnet add package RickDotNet.Apollo.Caching

For more information, visit the NuGet package page.

Usage

To use Apollo.Caching, you need to configure the service in your application's setup. Here's an example of how to register the distributed cache in your Startup.cs or program initialization:

using Apollo.Caching;
using Microsoft.Extensions.DependencyInjection;

var builder = Host.CreateApplicationBuilder(args);

// Add Apollo services
builder.Services
    .AddApollo(config)
    .AddCaching(); // This will register the NatsDistributedCache as IDistributedCache

var host = builder.Build();

// Now you can use IDistributedCache in your application
var cache = host.Services.GetRequiredService<IDistributedCache>();

await cache.SetAsync("my-key", "my-value"u8.ToArray(), new DistributedCacheEntryOptions
{
    AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(10)
});

var value = cache.Get("my-key");
Console.WriteLine($"[GET] {Encoding.UTF8.GetString(value!)}");

Configuration

The NatsDistributedCache can be configured with a custom bucket name by passing it to the constructor. If no bucket name is provided, it defaults to "apollocache".

Contributing

Contributions are welcome! Feel free to submit pull requests or create issues if you find bugs or have feature suggestions.

License

Apollo.Caching is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.1 69 4/27/2024
0.2.0 88 4/13/2024
0.1.1 77 3/24/2024
0.1.0 94 3/20/2024
0.0.5 63 3/10/2024
0.0.4 75 3/8/2024
0.0.3 88 3/3/2024