Persistence Caching
Caching persistence data in RCommon
Configuration
var host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
// Configure RCommon
services.AddRCommon()
.WithPersistence<EFCorePerisistenceBuilder>(ef => // Repository/ORM configuration. We could easily swap out to Linq2Db without impact to domain service up through the stack
{
// Add all the DbContexts here
ef.AddDbContext<TestDbContext>("TestDbContext", ef =>
{
ef.UseSqlServer(config.GetConnectionString("TestDbContext"));
});
ef.AddInMemoryPersistenceCaching(); // This gives us access to the caching repository interfaces/implementations
})
// You still need to configure this as well!
.WithMemoryCaching<InMemoryCachingBuilder>(cache =>
{
cache.Configure(x =>
{
x.ExpirationScanFrequency = TimeSpan.FromMinutes(1);
});
});
}).Build();
Usage
Behind the Scenes
Last updated