Skip to content

docs: align README examples with the current API - #10

Open
molon wants to merge 1 commit into
mainfrom
molon/readme-api-drift
Open

molon wants to merge 1 commit into
mainfrom
molon/readme-api-drift

Conversation

@molon

@molon molon commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

The same commit is also carried by #11 (as 5e99f15). Whichever of the two merges first, the other rebases cleanly.

Several README snippets (both English and Chinese) no longer compile against the current code:

README says Code has
NewRedisCache[T](client, prefix, ttl) NewRedisCache[T](&RedisCacheConfig{Client, KeyPrefix, TTL})
NewGORMCache(db, table, ttl) NewGORMCache[T](&GORMCacheConfig{DB, TableName, KeyPrefix}), no TTL
Cache[T].Set(ctx, key, value, ttl) Set(ctx, key, value)
return cachex.ErrKeyNotFound ErrKeyNotFound is a struct type: return &cachex.ErrKeyNotFound{}, check with IsErrKeyNotFound
JSONTransform[string, *User](stringCache) StringJSONTransform[*User](stringCache) (JSONTransform[T] takes Cache[[]byte])

This PR only touches README.md and README_ZH.md. I compiled the corrected snippets in a throwaway test before committing.

- NewRedisCache and NewGORMCache take a config struct, not positional args
- Cache[T].Set has no ttl parameter; expiry belongs to the Client or the backend config
- missing keys are signalled with *cachex.ErrKeyNotFound, checked via IsErrKeyNotFound
- the string JSON transform is StringJSONTransform[T], JSONTransform takes Cache[[]byte]
Copilot AI balanced review requested due to automatic review settings October 6, 2026 14:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

All documentation changes accurately reflect the current implementation.

Review effort: Balanced
Findings: None

What changed in this PR

Updates English and Chinese README examples to match the current Cachex API.

Changes:

  • Corrects backend constructors and Cache.Set.
  • Updates not-found error handling and JSON transformation examples.
  • Adds GORM migration examples.
File Description
README.md Aligns English examples with current APIs.
README_ZH.md Mirrors corrections in Chinese documentation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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