DistributedMemm is a C# library designed to provide distributed memory caching capabilities for .NET applications. By leveraging the power of RabbitMQ, this library ensures seamless data synchronization between multiple applications. In the event of cache data loss, DistributedMemm provides data recovery features using MongoDB.
- Distributed Caching: Extend the benefits of in-memory caching across multiple applications or instances.
- Data Synchronization: Using RabbitMQ, DistributedMemm ensures that data changes are broadcast and synchronized across all connected applications.
- Idempotency: Ensures that operations are processed once and only once, preventing duplicate data and actions.
- Data Recovery: With the backup mechanism in MongoDB, applications can restore their memory cache on startup, ensuring minimal downtime and data loss.
- Integrated API: An additional API that consumes RabbitMQ events to maintain and update MongoDB backup data.
- .NET Core or .NET 6+
- RabbitMQ Server
- MongoDB (if persist option enabled)
[Provide steps or code snippets to install and set up the library in a project]
-
Configuration: Set up your RabbitMQ and MongoDB configurations.
var config = new DistriCacheConfig { RabbitMQConnectionString = "YOUR_RABBITMQ_CONNECTION_STRING", MongoDBConnectionString = "YOUR_MONGODB_CONNECTION_STRING" };
-
Initialize DistributedMemm:
private readonly IDistributedMemm _distributedMemm; public TestService(IDistributedMemm distributedMemm) { _distributedMemm = distributedMemm; }
-
Usage:
_distributedMemm.Add("key", "value"); _distributedMemm.Add("key", new { Name = "jhon", SurName = "doe" }); var value = _distributedMemm.Get("key");
In case application restarts our library will try to restore data by calling reserve api.
We welcome contributions! Please see our CONTRIBUTING.md for details.
This project is licensed under [LICENSE NAME]. See the LICENSE file for details.