This repository demonstrates various caching strategies using ABP Framework with .NET Aspire integration. It includes examples of both Redis and Fusion caching implementations in a distributed environment.
- Setup basics
- Data seeding
- Can we get caching metrics in aspire?
- Add grafana, influxdb and k6 hosting
- Make sure we're doing sensible caching of products
- Get fusion cache example working
- .NET 9.0 SDK or later
- Node.js v18 or v20
- Redis (for distributed caching)
- Docker (optional, for containerized development)
The solution is organized into several projects:
AbpCachingPlayground.FusionCacheAppHost- Aspire host for Fusion Cache implementationAbpCachingPlayground.RedisCacheAppHost- Aspire host for Redis Cache implementationAbpCachingPlayground.ServiceDefaults- Shared service configurations
AbpCachingPlayground.Domain- Domain layerAbpCachingPlayground.Domain.Shared- Shared domain layerAbpCachingPlayground.Application.Contracts- Application contractsAbpCachingPlayground.Application- Application layerAbpCachingPlayground.EntityFrameworkCore- EF Core integrationAbpCachingPlayground.HttpApi- HTTP API layerAbpCachingPlayground.HttpApi.Client- HTTP API client
AbpCachingPlayground.AuthServer- Authentication serverAbpCachingPlayground.HttpApi.Host- API hostAbpCachingPlayground.Web- Web application
AbpCachingPlayground.DbMigrator- Database migration toolAbpCachingPlayground.TestBase- Testing infrastructure
- Clone the repository
git clone [your-repository-url]
cd AbpCachingPlayground- Install ABP CLI if you haven't already
dotnet tool install -g Volo.Abp.Cli- Install client-side dependencies
abp install-libs- Start the application using Aspire
cd aspire/AbpCachingPlayground.RedisCacheAppHost # or FusionCacheAppHost
dotnet runThe Redis implementation demonstrates distributed caching using Redis as the backing store. Key features include:
- Distributed cache implementation
- Cache invalidation strategies
- Cache-aside pattern examples
The Fusion implementation showcases memory caching with additional features:
- In-memory caching
- Double-checked locking pattern
- Cache eviction policies
- The solution uses .NET Aspire for orchestrating the microservices architecture
- Both Redis and Fusion cache implementations are available for comparison
- The
ServiceDefaultsproject contains shared configuration that's applied across all services - Test projects are available under the
testdirectory for each implementation
Update the Redis connection string in appsettings.json:
{
"Redis": {
"Configuration": "localhost:6379"
}
}Cache settings can be modified in the respective host projects:
{
"Cache": {
"DefaultExpirationTime": "00:30:00"
}
}Run the tests using:
dotnet testThe test projects include:
- Unit tests
- Integration tests
- Cache implementation tests
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.