πŸ›οΈ 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 μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ„ μœ„ν•œ μ§€λŠ₯ν˜• 캐싱 λΌμ΄λΈŒλŸ¬λ¦¬μž…λ‹ˆλ‹€. μ–΄νŠΈλ¦¬λ·°νŠΈ 기반의 선언적 캐싱과 μžλ™ λ¬΄νš¨ν™”λ₯Ό 톡해 κ°œλ°œμžκ°€ μΊμ‹œ 관리에 μ‹ κ²½ μ“°μ§€ μ•Šκ³ λ„ 높은 μ„±λŠ₯을 얻을 수 μžˆμŠ΅λ‹ˆλ‹€.

CI codecov NuGet Core License: MIT

⚑ 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) NuGet
Athena.Cache.Redis Redis λΆ„μ‚° 캐싱 지원 NuGet
Athena.Cache.Monitoring μ‹€μ‹œκ°„ λͺ¨λ‹ˆν„°λ§ 및 μ•Œλ¦Ό NuGet
Athena.Cache.Analytics κ³ κΈ‰ 뢄석 및 μΈμ‚¬μ΄νŠΈ NuGet
Athena.Cache.SourceGenerator 컴파일 νƒ€μž„ μ΅œμ ν™” NuGet

πŸš€ Get Started

Installation Guide Learn the Basics Core Features

🎯 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

πŸ“„ License

Athena.Cache is open source software licensed under the MIT License.


Made with ❀️ by Bruno Kim

⭐ Star us on GitHub if you find Athena.Cache useful!