Sloop 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Sloop --version 1.0.0
                    
NuGet\Install-Package Sloop -Version 1.0.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="Sloop" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sloop" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Sloop" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Sloop --version 1.0.0
                    
#r "nuget: Sloop, 1.0.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.
#:package Sloop@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Sloop&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Sloop&version=1.0.0
                    
Install as a Cake Tool

Maintainability Rating Coverage Maintainability Rating Reliability Rating Security Rating

โš“ Sloop

Sloop is a lightweight, PostgreSQL-backed implementation of IDistributedCache for .NET applications. It provides durable, high-performance caching with support for sliding and absolute expiration. Designed for simplicity and resilience in distributed systems.

โœจ Features

  • โšก Distributed key-value store backed by PostgreSQL
  • ๐Ÿ•“ Support for sliding and absolute expiration
  • ๐Ÿ” Safe for multi-instance use
  • ๐Ÿงน Periodic cleanup of expired entries
  • ๐Ÿงช Fully integration-tested with high coverage
  • ๐Ÿ“ฆ Compatible with Microsoft.Extensions.Caching.Abstractions
  • ๐Ÿ˜ Powered by Npgsql and Dapper
  • ๐Ÿ’‰ Simple, idiomatic DI registration

๐Ÿ“ฆ Installation

dotnet add package Sloop

Requires .NET 8.0 SDK or later

๐Ÿš€ Quick Start

Register with Dependency Injection

builder.Services.AddCache(options =>
{
    options.ConnectionString = builder.Configuration.GetConnectionString("Postgres")!;
    options.SchemaName = "public";
    options.TableName = "cache";
    options.DefaultExpiration = TimeSpan.FromMinutes(30); // optional
});

Use the IDistributedCache

public class MyService
{
    private readonly IDistributedCache _cache;

    public MyService(IDistributedCache cache)
    {
        _cache = cache;
    }

    public async Task UseCacheAsync()
    {
        var key = "user:123";
        var data = await _cache.GetStringAsync(key);

        if (data == null)
        {
            data = "example";
            await _cache.SetStringAsync(key, data, new DistributedCacheEntryOptions
            {
                SlidingExpiration = TimeSpan.FromMinutes(10),
                AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(1)
            });
        }
    }
}

๐Ÿงช Testing

Tests are executed against disposable PostgreSQL containers via Testcontainers:

dotnet test

๐Ÿค Contributing

Contributions are welcome! Please follow standard C# coding guidelines and include tests with pull requests.

๐Ÿ“„ License

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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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
2.1.2 708 11/6/2025
2.1.1 999 7/23/2025
2.1.0 589 7/23/2025
2.0.0 599 7/21/2025
1.0.3 197 5/29/2025
1.0.2 201 5/29/2025
1.0.1 201 5/27/2025
1.0.0 147 5/23/2025