Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🚀 Summary
This PR introduces a high-performance, pluggable caching module to the GoFr framework. It allows seamless injection and usage of either in-memory or Redis-based cache implementations across application layers with support for future observability and middleware extensibility.
This implements Phase 1 of the "Unified Cache Layer" as proposed in the GoFr Summer of Code framework extensions.
🎯 Motivation
GoFr previously lacked a unified caching abstraction, which led developers to implement manual and inconsistent caching logic. This PR standardizes cache usage via:
Cache
interfaceapp.Container.Set("cache", ...)
🧩 What's Implemented
Cache
interface: definesGet
,Set
,Delete
, andWrapQuery
go-redis/v9
Container.Set()
📦 Example Usage
Registering the cache in
main.go
Using it in application logic (service or store layer)
Optional: WrapQuery (Phase 2 Preview)
🧪 Tests
📂 Affected Files
📊 Observability (Planned)
cache_hits_total
,cache_misses_total
,cache_errors_total
cache.Get
,cache.Set
,cache.WrapQuery
WithLogging(cache, logger)
wrapper🗒 Related
Closes issue: TBD by maintainers
Proposal: Unified Cache Layer – Phase 1 (Application-level injection)
🙌 Notes for Reviewers
Future PRs will extend this with query wrapping logic, metrics, and trace hooks.
Note: The
Container
is a struct. We useapp.Container.Set("cache", cache)
to register dependencies.