ServiceBricks.Cache.Microservice 1.4.0

dotnet add package ServiceBricks.Cache.Microservice --version 1.4.0
                    
NuGet\Install-Package ServiceBricks.Cache.Microservice -Version 1.4.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="ServiceBricks.Cache.Microservice" Version="1.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ServiceBricks.Cache.Microservice" Version="1.4.0" />
                    
Directory.Packages.props
<PackageReference Include="ServiceBricks.Cache.Microservice" />
                    
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 ServiceBricks.Cache.Microservice --version 1.4.0
                    
#r "nuget: ServiceBricks.Cache.Microservice, 1.4.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 ServiceBricks.Cache.Microservice@1.4.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=ServiceBricks.Cache.Microservice&version=1.4.0
                    
Install as a Cake Addin
#tool nuget:?package=ServiceBricks.Cache.Microservice&version=1.4.0
                    
Install as a Cake Tool

ServiceBricks Logo

NuGet version badge License: MIT

ServiceBricks Cache Microservice

Overview

This repository contains the cache microservice built using the ServiceBricks foundation. The cache microservice exposes a key/value pair object that can be used for simple data storage. It includes a semaphore, exposing a locking mechanism that can be used by multiple servers when needing to access a shared resource. A background expiration task can be enabled, with an initial delay and interval, to delete expired cache items once their expiration date occurs. The expiration process duals as an orphaned lock cleanup, should a lock not be released within the timeout period.

Data Transfer Objects

CacheDataDto - Admin Policy

Key and Value pair storage object along with an expiration date to denote when it can be deleted.


    public partial class CacheDataDto : DataTransferObject
    {
        public DateTimeOffset CreateDate { get; set; }
        public DateTimeOffset UpdateDate { get; set; }
        public string CacheKey { get; set; }
        public string CacheValue { get; set; }
        public DateTimeOffset? ExpirationDate { get; set; }

    }

Background Tasks and Timers

CacheExpirationTimer class

This background timer can be enabled, with an initial delay and interval, to execute the CacheExpirationTask.

View Source

CacheExpirationTask class

This background task queries for all CacheData records with an expiration date is less than the current date/time, then deletes expired records.

View Source

Events

None

Processes

None

Service Bus

None

Additional Services

SemaphoreService

This provides a locking mechanism for shared resources in the infrastructure. Using the CacheData object, multiple concurrent services try creating the same key/record in the backing storage, the one that wins pulls records, then releases/deletes the lock. Processes will delay and retry creating the lock until it obtains it or times out. See the SemaphoreOptions for the full list of values used.

View Source

SingleServerProcessService

This interface stores a key in cache used for syncing across load-balanced applications so that only one server would process records at a time (see SingleWorkService). It provides a heartbeat, so that other instances will pickup and start processing, should the main running server be shut down.

View Source

SingleWorkService class

This abstract class implements the WorkService and the ISingleServerProcessService to provide a single ordered work queue across multi-application instances.

View Source

LockedWorkService class

This abstract class provides a way to lock the underlying data store and use it as a queue, so that multiple, simultaneous running workers do not return the same records. While the APIConcurrrency rule provides some protection, this class will provide the full solution.

View Source

Application Settings

{
    "ServiceBricks":{
	  "Cache":{
	   "Expiration": {
		  "TimerEnabled": false,
		  "TimerIntervalMilliseconds": 7000,
		  "TimerDueMilliseconds": 1000
	   },
	   "Semaphore": {
		  "DelayMilliseconds": 3000,
		  "CancellationMilliseconds": 20000,
		  "OrphanTimeoutMilliseconds": 10000
	   }
    }
  }
}

About ServiceBricks

ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 is compatible.  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
1.4.0 24 1/1/2026
1.4.0-e 267 12/18/2025
1.4.0-d 259 12/16/2025
1.4.0-c 283 12/14/2025
1.4.0-a 343 12/7/2025
1.3.0 380 3/18/2025
1.3.0-c 240 3/16/2025
1.3.0-a 200 1/27/2025
1.2.0 120 1/14/2025
1.1.3 165 12/1/2024