ποΈ Athena.Cache
Smart caching library for ASP.NET Core with automatic query parameter key generation and table-based cache invalidation.
Athena.Cacheλ ASP.NET Core μ ν리μΌμ΄μ μ μν μ§λ₯ν μΊμ± λΌμ΄λΈλ¬λ¦¬μ λλ€. μ΄νΈλ¦¬λ·°νΈ κΈ°λ°μ μ μΈμ μΊμ±κ³Ό μλ 무ν¨νλ₯Ό ν΅ν΄ κ°λ°μκ° μΊμ κ΄λ¦¬μ μ κ²½ μ°μ§ μκ³ λ λμ μ±λ₯μ μ»μ μ μμ΅λλ€.
β‘ Quick Start
1. Install Package
dotnet add package Athena.Cache.Core
2. Configure Services
// Program.cs
builder.Services.AddAthenaCacheComplete(options => {
options.Namespace = "MyApp";
options.DefaultExpirationMinutes = 30;
});
var app = builder.Build();
app.UseRouting();
app.UseAthenaCache(); // Add after routing
app.MapControllers();
3. Use in Controllers
[ApiController]
[Route("api/[controller]")]
public class UsersController : ControllerBase
{
[HttpGet]
[AthenaCache(ExpirationMinutes = 30)]
[CacheInvalidateOn("Users")]
public async Task<ActionResult<IEnumerable<UserDto>>> GetUsers()
{
// This will be automatically cached
// Cache will be invalidated when Users table changes
return Ok(await _userService.GetUsersAsync());
}
}
Thatβs it! Your API responses are now cached automatically.
β¨ Key Features
Automatic Caching
Simply add [AthenaCache]
to your controller actions. Cache keys are automatically generated from method parameters.
Smart Invalidation
Use [CacheInvalidateOn("TableName")]
to automatically invalidate cache when database tables change.
Zero Memory
Advanced memory optimization techniques reduce allocations by up to 98% for high-performance applications.
Distributed Ready
Seamless Redis integration for distributed caching across multiple application instances.
Source Generator
Compile-time optimizations eliminate reflection overhead and enable AOT compilation support.
Built-in Monitoring
Real-time dashboards, performance metrics, and analytics to optimize your cache performance.
π¦ Package Ecosystem
Athena.Cacheλ λͺ¨λμ ν¨ν€μ§ μμ€ν μΌλ‘ νμν κΈ°λ₯λ§ μ νν΄μ μ¬μ©ν μ μμ΅λλ€.
Package | Description | NuGet |
---|---|---|
Athena.Cache.Core | κΈ°λ³Έ μΊμ± κΈ°λ₯ (MemoryCache) | |
Athena.Cache.Redis | Redis λΆμ° μΊμ± μ§μ | |
Athena.Cache.Monitoring | μ€μκ° λͺ¨λν°λ§ λ° μλ¦Ό | |
Athena.Cache.Analytics | κ³ κΈ λΆμ λ° μΈμ¬μ΄νΈ | |
Athena.Cache.SourceGenerator | μ»΄νμΌ νμ μ΅μ ν |
π Get Started
π― Why Athena.Cache?
Before Athena.Cache
public async Task<UserDto> GetUser(int id)
{
var cacheKey = $"user_{id}";
if (_cache.TryGetValue(cacheKey, out UserDto cached))
return cached;
var user = await _userService.GetUserAsync(id);
_cache.Set(cacheKey, user, TimeSpan.FromMinutes(30));
return user;
}
// When user is updated, you need to remember to invalidate cache
public async Task UpdateUser(UserDto user)
{
await _userService.UpdateUserAsync(user);
// Don't forget this! (but you probably will)
_cache.Remove($"user_{user.Id}");
_cache.Remove("users_list");
// ... and many more related caches
}
With Athena.Cache
[HttpGet("{id}")]
[AthenaCache(ExpirationMinutes = 30)]
public async Task<UserDto> GetUser(int id)
{
return await _userService.GetUserAsync(id);
}
[HttpPut("{id}")]
[CacheInvalidateOn("Users")] // Automatically invalidates all related caches
public async Task UpdateUser(int id, [FromBody] UserDto user)
{
await _userService.UpdateUserAsync(user);
}
κ·Έκ² μ λΆμ λλ€! μΊμ ν€ μμ±, μ μ₯, 무ν¨νκ° λͺ¨λ μλμΌλ‘ μ²λ¦¬λ©λλ€.
π Community & Support
- π Documentation: Comprehensive guides and API reference
- π Issues: Report bugs and request features
- π¬ Discussions: Ask questions and share experiences
- π Examples: Sample applications and use cases
π License
Athena.Cache is open source software licensed under the MIT License.