NetModules.Cache.MemoryCache
1.3.8
dotnet add package NetModules.Cache.MemoryCache --version 1.3.8
NuGet\Install-Package NetModules.Cache.MemoryCache -Version 1.3.8
<PackageReference Include="NetModules.Cache.MemoryCache" Version="1.3.8" />
<PackageVersion Include="NetModules.Cache.MemoryCache" Version="1.3.8" />
<PackageReference Include="NetModules.Cache.MemoryCache" />
paket add NetModules.Cache.MemoryCache --version 1.3.8
#r "nuget: NetModules.Cache.MemoryCache, 1.3.8"
#:package NetModules.Cache.MemoryCache@1.3.8
#addin nuget:?package=NetModules.Cache.MemoryCache&version=1.3.8
#tool nuget:?package=NetModules.Cache.MemoryCache&version=1.3.8
NetModules.Cache
NetModules.Cache is a basic event caching module that is built using the NetModules architecture.
This repository consists of two libraries:
- NetModules.Cache.MemoryCache: A library that contains a basic in-memory caching module.
- NetModules.Cache.Events: A library that contains helper events for testing cached events, and requesting cached data on demand.
It enables a simple in-memory caching solution for NetModules Events and can be configured to cache any event type that implements the IEvent
interface, with the exception of an event that has assigned a strict handler using the EventHandlerAttribute
.
A Module doesn't need to worry about how event caching is handled unless it's an event caching Module!
Applications that frequently process identical event requests benefit from caching to reduce redundant processing and speed up response times. MemoryCacheModule provides an efficient caching layer by:
- Storing event output based on event names and input parameters.
- Allowing modules to control caching behavior dynamically.
- Providing fine-grained cache expiration management.
Features
- Event-Based Caching: Stores event output using input parameters as cache keys.
- Dynamic Expiry Control: Set custom expiration times per event.
- Metadata-Driven Behavior: Control caching at runtime using event metadata.
- Efficient Handling: Automatically retrieves cached data when available.
Getting Started
Installation
To use NetModules.Cache, MemoryCacheModule
, add the library to your ModuleHost
project via NuGet Package Manager:
Install-Package NetModules.Cache.MemoryCache
To use NetModules.Cache.Events, and request cache data on demand from another module, add the events library to your Module
project via NuGet Package Manager:
Install-Package NetModules.Cache.Events
While not required, NetModules.Cache.Events contains events that can be handled by an event caching module, to return a cached event output on demand. A usage example could be a clustering module system, where a peer may request a cached output from another peer.
Setup and Configuration
When you install MemoryCacheModule
, it will automatically register itself with the ModuleHost
and start caching events using the default configuration (see included file: NetModules.Cache.MemoryCache.MemoryCacheModule.settings.default.json
). You can configure the caching behavior by creating your own settings file "NetModules.Cache.MemoryCache.MemoryCacheModule.settings.json"
and modifying/adding settings accordingly.
To add your own configuration to NetModules.Cache.MemoryCache MemoryCacheModule
, a module that can handle a GetSettingEvent is required in your ModuleHost
project.
See: NetModules.Settings.LocalSettings for more information.
Here is an example configuration file that will cache all events for 1 hour, but only cache MyCustomModuleEvents.MyExampleEventName
event for 1 second...
{
"defaultExpire": 3600,
"expire": {
"NetModules.Events.LoggingEvent": 0,
"MyCustomModuleEvents.MyExampleEventName": 1
},
"cacheWithMeta": true,
"excludeMetaKeys": ["id", "handlers"],
"cacheUniqueKeys": true
}
For more advanced event caching, consider creating/using a module that implements a dedicated caching service, a dedicated framework such as Memcached, or reading/writing cache to dedicated Redis Enterprise cache designed for caching at scale. This module can be used as a reference.
Contributing
We welcome contributions! To get involved:
- Fork NetModules.Cache, make improvements, and submit a pull request.
- Code will be reviewed upon submission.
- Join discussions via the issues board.
License
NetModules.Cache is licensed under the MIT License, allowing unrestricted use, modification, and distribution. If you use NetModules.Cache in your own project, we’d love to hear about your experience, and possibly feature you on our website!
Full documentation coming soon!
This project references NetTools.Cache for strict ICachedObject and ICacheController implementation.
Product | Versions 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 was computed. 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 was computed. 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 was computed. 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. |
-
net6.0
- NetModules (>= 1.3.8)
- NetModules.Cache.Events (>= 1.3.8)
- NetTools.Cache (>= 1.2.0)
- NetTools.Serialization.Json (>= 1.1.39)
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.3.8 | 227 | 5/14/2025 |