use waddling_errors_macros::{component, component_location, diag};
component_location!(Cache, role = developer);
component! {
Cache {
docs: "Redis caching layer. Handles cache operations, TTL management, and cache invalidation strategies.",
examples: [
"E.Cache.Connection.UNAVAILABLE: Redis server unavailable",
"W.Cache.Data.STALE: Cache entry stale, refreshing from DB",
"S.Cache.Data.WARMED: Cache warmed successfully"
],
tags: ["performance", "redis", "memory"],
},
}
diag! {
<json, html>,
E.Cache.Connection.UNAVAILABLE: {
message: "Redis cache server unavailable",
'CR 'Pub description: "The Redis cache server is temporarily unavailable. Operations will fall back to the primary data source.",
'CR 'Pub hints: [
"Check Redis server status",
"Verify network connectivity"
],
'CR 'Int hints: [
"Review Redis logs for errors",
"Check Redis memory usage",
"Verify Redis persistence settings"
],
'R role: "Internal",
'R tags: ["cache", "redis", "connectivity"],
},
W.Cache.Data.STALE: {
message: "Cache entry stale - refreshing from database",
'CR 'Pub description: "The cached entry has exceeded its TTL and is considered stale. The system will refresh the value from the primary data source.",
'CR 'Pub hints: [
"Refresh from source",
"Adjust TTL settings"
],
'CR 'Dev hints: [
"Consider implementing cache warming",
"Review TTL configuration for this key pattern"
],
'R role: "Developer",
'R tags: ["cache", "ttl", "refresh"],
},
I.Cache.Data.MISS: {
message: "Cache miss - fetching from primary source",
'CR 'Pub description: "The requested key was not found in the cache. The value will be fetched from the primary data source and cached.",
'CR 'Pub hints: [
"This is normal behavior"
],
'CR 'Dev hints: [
"Consider preloading frequently accessed keys",
"Monitor cache hit ratio"
],
'R role: "Developer",
'R tags: ["cache", "performance"],
},
S.Cache.Data.WARMED: {
message: "Cache successfully warmed with fresh data",
'CR 'Pub description: "The cache warming operation completed successfully. Frequently accessed data has been preloaded into cache.",
'CR 'Pub hints: [
"Cache ready for optimal performance"
],
'CR 'Dev hints: [
"Monitor cache hit rates",
"Review warmup key selection"
],
'R role: "Developer",
'R tags: ["cache", "warmup", "performance"],
},
}