Implements memory context for caching and data persistence in applications, allowing for efficient data retrieval and storage.
$ dotnet add package Pavas.Runtime.MemoryContextPavas.Runtime.MemoryContext is a library designed to manage in-memory contexts for caching or quick data retrieval operations. This library is particularly useful for applications that require fast access to certain datasets or need to maintain a temporary state in memory.
To use this library, include it in your project through dependency injection.
Define the memory repositories during the project initialization:
string[] repositories = [
"Name1",
"Name2",
...etc
];
or use Repository entity, provides name and default data
```csharp
List<Repository> repositories = [
new Repository("Name1", [])
new Repository("Name2", [])
];
```
2. Inject the context into the service during the application service configuration:
```csharp
builder.Services.AddMemoryContext(repositories);
```
The MemoryContextMiddleware can be used to manage memory contexts throughout the lifecycle of the application:
app.UseMemoryContextMiddleware();
This middleware will ensure that the memory context is properly initialized and disposed of during each request.
This project is under continuous development. If you wish to contribute, please fork the repository, create a new branch, and submit a pull request.
This project is licensed under the terms of the MIT License.