Skip to content

Conversation

@evangwt
Copy link
Owner

@evangwt evangwt commented Aug 15, 2025

This pull request refactors the grc GORM cache plugin to use a clean, abstract cache interface and removes the direct dependency on go-redis. The documentation and examples are updated to reflect a backend-agnostic, pluggable architecture. Tests and example code now use SQLite and in-memory cache by default, making the project easier to use and test without external dependencies.

Major architectural changes:

  • The cache backend is now defined by a simple CacheClient interface, allowing users to implement any storage backend (memory, Redis, Memcached, file, etc.) and switch backends without changing application code. (README.md, cache.go) [1] [2]

  • All direct usage of go-redis and related code has been removed from the core library and tests. Redis support is now optional via a separate, simple client implementation. (cache.go, cache_test.go, example/main.go) [1] [2] [3]

Documentation and examples:

  • The README.md is rewritten to highlight the new architecture, usage patterns, cache control, available implementations, migration guide, and contribution instructions. (README.md)

  • Example code now uses SQLite and MemoryCache for demonstration, with Redis usage shown as an optional, commented-out section. (example/main.go, example/memory_example.go) [1] [2] [3]

Testing improvements:

  • Tests now use an in-memory cache implementation and skip execution if required environment variables for the database are missing, improving portability and reliability. (cache_test.go) [1] [2]

Error handling and API consistency:

  • Introduced a standard ErrCacheMiss error for cache misses, replacing backend-specific error handling. (cache.go) [1] [2]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants