mirror of
https://github.com/azaion/admin.git
synced 2026-04-22 11:46:33 +00:00
[AZ-189] [AZ-190] [AZ-191] [AZ-192] [AZ-193] [AZ-194] [AZ-195] Add e2e blackbox test suite
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
# Module: Azaion.Services.Cache
|
||||
|
||||
## Purpose
|
||||
In-memory caching abstraction using LazyCache, providing get-or-add and invalidation operations.
|
||||
|
||||
## Public Interface
|
||||
|
||||
### ICache
|
||||
| Method | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| `GetFromCacheAsync<T>` | `Task<T> GetFromCacheAsync<T>(string key, Func<Task<T>> fetchFunc, TimeSpan? expiration = null)` | Returns cached value or fetches and caches it |
|
||||
| `Invalidate` | `void Invalidate(string key)` | Removes a key from the cache |
|
||||
|
||||
### MemoryCache (implementation)
|
||||
Default expiration: 4 hours (`TimeSpan.FromHours(4)`).
|
||||
|
||||
## Internal Logic
|
||||
Wraps `LazyCache.CachingService`. `GetFromCacheAsync` uses `GetOrAddAsync` with absolute expiration relative to now. `Invalidate` calls `Remove`.
|
||||
|
||||
## Dependencies
|
||||
- LazyCache (`IAppCache`, `CachingService`)
|
||||
|
||||
## Consumers
|
||||
- `UserService.GetByEmail` — caches user lookups by `User.GetCacheKey(email)`
|
||||
- `UserService.UpdateHardware`, `UserService.UpdateQueueOffsets`, `UserService.CheckHardwareHash` — invalidate cache after writes
|
||||
- Registered as `Scoped` in DI (`Program.cs`): `AddScoped<ICache, MemoryCache>`
|
||||
|
||||
## Data Models
|
||||
None.
|
||||
|
||||
## Configuration
|
||||
None — default 4-hour expiration is hardcoded.
|
||||
|
||||
## External Integrations
|
||||
None.
|
||||
|
||||
## Security
|
||||
None.
|
||||
|
||||
## Tests
|
||||
`MemoryCache` is instantiated directly in `UserServiceTest`.
|
||||
Reference in New Issue
Block a user