Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔥 Add Cache Invalidation Option to Cache Middleware #3036

Merged
merged 10 commits into from
Jun 26, 2024

Conversation

hcancelik
Copy link
Contributor

Description

This is a new option for the cache middleware to invalidate the cache. This is based on the discussion at #3034

Changes introduced

  • Benchmarks: Describe any performance benchmarks and improvements related to the changes.
  • Documentation Update: Detail the updates made to the documentation and links to the changed files.
  • Changelog/What's New: Include a summary of the additions for the upcoming release notes.
  • Migration Guide: If necessary, provide a guide or steps for users to migrate their existing code to accommodate these changes.
  • API Alignment with Express: Explain how the changes align with the Express API.
  • API Longevity: Discuss the steps taken to ensure that the new or updated APIs are consistent and not prone to breaking changes.
  • Examples: Provide examples demonstrating the new features or changes in action.

Type of change

  • Enhancement (improvement to existing features and functionality)

Checklist

  • Followed the inspiration of the Express.js framework for new functionalities, making them similar in usage.
  • Conducted a self-review of the code and provided comments for complex or critical parts.
  • Updated the documentation in the /docs/ directory for Fiber's documentation.
  • Added or updated unit tests to validate the effectiveness of the changes or new features.
  • Ensured that new and existing unit tests pass locally with the changes.
  • Verified that any new dependencies are essential and have been agreed upon by the maintainers/community.
  • Aimed for optimal performance with minimal allocations in the new code.
  • Provided benchmarks for the new code to analyze and improve upon.

@hcancelik hcancelik requested a review from a team as a code owner June 14, 2024 15:46
@hcancelik hcancelik requested review from gaby, sixcolors, ReneWerner87 and efectn and removed request for a team June 14, 2024 15:46
Copy link

welcome bot commented Jun 14, 2024

Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

Copy link
Contributor

coderabbitai bot commented Jun 14, 2024

Walkthrough

The update introduces the CacheInvalidator property to the caching middleware's Config struct, allowing manual cache invalidation based on custom conditions. Additionally, an example is provided in the documentation to illustrate its usage. Furthermore, tests were added to ensure the cache invalidation logic works correctly.

Changes

Files Change Summaries
docs/middleware/cache.md Added CacheInvalidator property to Config struct with a description and example usage.
docs/whats_new.md Documented the new Cache Invalidation feature in the caching middleware.
middleware/cache/cache.go Updated New function to include cache invalidation logic based on CacheInvalidation configuration.
middleware/cache/cache_test.go Added Test_CacheInvalidation to test cache invalidation logic.
middleware/cache/config.go Introduced CacheInvalidator field to Config struct, initialized to nil in ConfigDefault variable.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Client
    participant CacheMiddleware
    participant CacheStorage

    Client->>CacheMiddleware: Request Data
    CacheMiddleware->>CacheInvalidator: Check Cache Invalidator Function
    CacheInvalidator-->>CacheMiddleware: Returns True/False
    alt Cache Invalidated
        CacheMiddleware->>CacheStorage: Invalidate Cache Entry
    end
    CacheMiddleware->>CacheStorage: Get Cache Data
    CacheStorage-->>CacheMiddleware: Return Data
    CacheMiddleware-->>Client: Respond with Data
Loading

Poem

🐇✨
In the land of code, where caches stay,
A rabbit hops to clear the way,
With CacheInvalidator keen and bright,
It clears the old to keep things right.
Enhanced by paws so swift and light,
Now caches vanish out of sight.
✨🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 23bcbd3 and d8f0d5c.

Files selected for processing (5)
  • docs/middleware/cache.md (2 hunks)
  • docs/whats_new.md (1 hunks)
  • middleware/cache/cache.go (1 hunks)
  • middleware/cache/cache_test.go (1 hunks)
  • middleware/cache/config.go (2 hunks)
Additional context used
Markdownlint
docs/middleware/cache.md

55-55: Column: 1 (MD010, no-hard-tabs)
Hard tabs


99-99: Column: 1 (MD010, no-hard-tabs)
Hard tabs

docs/whats_new.md

49-49: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


50-50: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


51-51: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


52-52: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


53-53: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


54-54: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


55-55: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


59-59: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


60-60: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


61-61: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


65-65: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


66-66: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


67-67: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


68-68: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


69-69: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


73-73: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


74-74: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


75-75: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


192-192: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


193-193: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


194-194: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


195-195: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


196-196: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


197-197: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


198-198: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


199-199: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


200-200: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


201-201: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


205-205: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


206-206: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


207-207: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


208-208: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


209-209: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


210-210: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


211-211: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


212-212: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


213-213: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


214-214: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


215-215: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


219-219: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


220-220: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


221-221: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


229-229: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


278-278: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


189-189: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


242-242: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


299-299: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


259-259: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


262-262: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


143-143: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


171-171: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


23-23: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


260-260: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines

LanguageTool
docs/whats_new.md

[grammar] ~51-~51: It looks like there is a word missing here. Did you mean “listen to config”? (LISTEN_TO_ME)
Context: ...ic.md) * app.Config properties moved to listen config * DisableStartupMessage * EnablePre...


[style] ~55-~55: This adverb was used twice in the sentence. Consider removing one of them or replacing them with a synonym. (ADVERB_REPETITION_PREMIUM)
Context: ...nablePrintRoutes * ListenerNetwork -> previously Network ### new methods * RegisterCus...


[uncategorized] ~192-~192: The official spelling of this programming framework is “Express.js”. (NODE_JS)
Context: ... ::: ### new methods * AutoFormat -> ExpressJs like * Host -> ExpressJs like * Port ->...


[uncategorized] ~193-~193: The official spelling of this programming framework is “Express.js”. (NODE_JS)
Context: ... AutoFormat -> ExpressJs like * Host -> ExpressJs like * Port -> ExpressJs like * IsProxy...


[uncategorized] ~194-~194: The official spelling of this programming framework is “Express.js”. (NODE_JS)
Context: ...like * Host -> ExpressJs like * Port -> ExpressJs like * IsProxyTrusted * Reset * Schema ...


[uncategorized] ~197-~197: The official spelling of this programming framework is “Express.js”. (NODE_JS)
Context: ...ke * IsProxyTrusted * Reset * Schema -> ExpressJs like * SendStream -> ExpressJs like * S...


[uncategorized] ~198-~198: The official spelling of this programming framework is “Express.js”. (NODE_JS)
Context: ...chema -> ExpressJs like * SendStream -> ExpressJs like * SendString -> ExpressJs like * S...


[uncategorized] ~199-~199: The official spelling of this programming framework is “Express.js”. (NODE_JS)
Context: ...tream -> ExpressJs like * SendString -> ExpressJs like * String -> ExpressJs like * ViewB...


[uncategorized] ~200-~200: The official spelling of this programming framework is “Express.js”. (NODE_JS)
Context: ...endString -> ExpressJs like * String -> ExpressJs like * ViewBind -> instead of Bind ###...


[grammar] ~253-~253: Do not use the singular ‘a’ before the plural noun ‘conditions’. (VB_A_JJ_NNS)
Context: ...ache management, allowing you to define a custom conditions for invalidating cache entries. ### CO...


[style] ~257-~257: Consider rephrasing this to strengthen your wording. (MAKE_CHANGES)
Context: ...idating cache entries. ### CORS We've made some changes to the CORS middleware to improve its f...


[uncategorized] ~265-~265: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...updated fields: - Config.AllowOrigins: Now accepts a slice of strings, each re...


[uncategorized] ~266-~266: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ... allowed origin. - Config.AllowMethods: Now accepts a slice of strings, each re...


[uncategorized] ~267-~267: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ... allowed method. - Config.AllowHeaders: Now accepts a slice of strings, each re...


[uncategorized] ~268-~268: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...allowed header. - Config.ExposeHeaders: Now accepts a slice of strings, each re...

Additional comments not posted (5)
middleware/cache/config.go (2)

34-38: New property CacheInvalidation added to Config struct. Ensure that the documentation is clear and the default value (nil) is appropriate. This allows users to define custom logic for cache invalidation.


81-81: The default value for CacheInvalidation is set to nil in ConfigDefault. This is consistent with the optional nature of this new feature.

docs/middleware/cache.md (1)

65-73: The documentation for the CacheInvalidation function is clear and provides a practical example of usage. Ensure the example aligns with typical use cases and is easy to understand for users.

docs/whats_new.md (1)

253-253: The announcement of the new cache invalidation feature in the caching middleware is well-articulated. It clearly explains the benefit of allowing users to define custom conditions for invalidating cache entries.

Tools
LanguageTool

[grammar] ~253-~253: Do not use the singular ‘a’ before the plural noun ‘conditions’. (VB_A_JJ_NNS)
Context: ...ache management, allowing you to define a custom conditions for invalidating cache entries. ### CO...

middleware/cache/cache_test.go (1)

700-732: The implementation of Test_CacheInvalidation looks thorough, correctly setting up the scenario to test the new cache invalidation feature. However, consider adding assertions for the HTTP status codes and possibly the cache headers to ensure that the cache is indeed being hit or missed as expected.

middleware/cache/cache.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jun 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.81%. Comparing base (ba6ea67) to head (a8e50e3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3036      +/-   ##
==========================================
+ Coverage   82.78%   82.81%   +0.02%     
==========================================
  Files         115      115              
  Lines        8227     8229       +2     
==========================================
+ Hits         6811     6815       +4     
+ Misses       1086     1084       -2     
  Partials      330      330              
Flag Coverage Δ
unittests 82.81% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gaby
Copy link
Member

gaby commented Jun 14, 2024

@hcancelik I think the name doesnt make it clear what it is, it could be a func or param. Something more appropiate would be:

  • InvalidateCacheFunc
  • CacheInvalidator
  • CacheInvalidationFunc

@ReneWerner87 ReneWerner87 linked an issue Jun 15, 2024 that may be closed by this pull request
3 tasks
@ReneWerner87 ReneWerner87 added this to the v3 milestone Jun 15, 2024
@hcancelik
Copy link
Contributor Author

hcancelik commented Jun 15, 2024

@gaby appreciate your feedback. I have renamed it to CacheInvalidator.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d8f0d5c and b26eb02.

Files selected for processing (5)
  • docs/middleware/cache.md (2 hunks)
  • docs/whats_new.md (1 hunks)
  • middleware/cache/cache.go (1 hunks)
  • middleware/cache/cache_test.go (1 hunks)
  • middleware/cache/config.go (2 hunks)
Files skipped from review as they are similar to previous changes (3)
  • middleware/cache/cache.go
  • middleware/cache/cache_test.go
  • middleware/cache/config.go
Additional context used
Markdownlint
docs/middleware/cache.md

55-55: Column: 1 (MD010, no-hard-tabs)
Hard tabs


99-99: Column: 1 (MD010, no-hard-tabs)
Hard tabs

docs/whats_new.md

49-49: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


50-50: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


51-51: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


52-52: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


53-53: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


54-54: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


55-55: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


59-59: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


60-60: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


61-61: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


65-65: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


66-66: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


67-67: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


68-68: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


69-69: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


73-73: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


74-74: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


75-75: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


192-192: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


193-193: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


194-194: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


195-195: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


196-196: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


197-197: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


198-198: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


199-199: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


200-200: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


201-201: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


205-205: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


206-206: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


207-207: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


208-208: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


209-209: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


210-210: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


211-211: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


212-212: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


213-213: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


214-214: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


215-215: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


219-219: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


220-220: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


221-221: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


229-229: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


278-278: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


189-189: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


242-242: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


299-299: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


259-259: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


262-262: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


143-143: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


171-171: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


23-23: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


260-260: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines

LanguageTool
docs/whats_new.md

[grammar] ~51-~51: It looks like there is a word missing here. Did you mean “listen to config”? (LISTEN_TO_ME)
Context: ...ic.md) * app.Config properties moved to listen config * DisableStartupMessage * EnablePre...


[style] ~55-~55: This adverb was used twice in the sentence. Consider removing one of them or replacing them with a synonym. (ADVERB_REPETITION_PREMIUM)
Context: ...nablePrintRoutes * ListenerNetwork -> previously Network ### new methods * RegisterCus...


[uncategorized] ~192-~192: The official spelling of this programming framework is “Express.js”. (NODE_JS)
Context: ... ::: ### new methods * AutoFormat -> ExpressJs like * Host -> ExpressJs like * Port ->...


[uncategorized] ~193-~193: The official spelling of this programming framework is “Express.js”. (NODE_JS)
Context: ... AutoFormat -> ExpressJs like * Host -> ExpressJs like * Port -> ExpressJs like * IsProxy...


[uncategorized] ~194-~194: The official spelling of this programming framework is “Express.js”. (NODE_JS)
Context: ...like * Host -> ExpressJs like * Port -> ExpressJs like * IsProxyTrusted * Reset * Schema ...


[uncategorized] ~197-~197: The official spelling of this programming framework is “Express.js”. (NODE_JS)
Context: ...ke * IsProxyTrusted * Reset * Schema -> ExpressJs like * SendStream -> ExpressJs like * S...


[uncategorized] ~198-~198: The official spelling of this programming framework is “Express.js”. (NODE_JS)
Context: ...chema -> ExpressJs like * SendStream -> ExpressJs like * SendString -> ExpressJs like * S...


[uncategorized] ~199-~199: The official spelling of this programming framework is “Express.js”. (NODE_JS)
Context: ...tream -> ExpressJs like * SendString -> ExpressJs like * String -> ExpressJs like * ViewB...


[uncategorized] ~200-~200: The official spelling of this programming framework is “Express.js”. (NODE_JS)
Context: ...endString -> ExpressJs like * String -> ExpressJs like * ViewBind -> instead of Bind ###...


[grammar] ~253-~253: Do not use the singular ‘a’ before the plural noun ‘conditions’. (VB_A_JJ_NNS)
Context: ...ache management, allowing you to define a custom conditions for invalidating cache entries. ### CO...


[style] ~257-~257: Consider rephrasing this to strengthen your wording. (MAKE_CHANGES)
Context: ...idating cache entries. ### CORS We've made some changes to the CORS middleware to improve its f...


[uncategorized] ~265-~265: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...updated fields: - Config.AllowOrigins: Now accepts a slice of strings, each re...


[uncategorized] ~266-~266: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ... allowed origin. - Config.AllowMethods: Now accepts a slice of strings, each re...


[uncategorized] ~267-~267: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ... allowed method. - Config.AllowHeaders: Now accepts a slice of strings, each re...


[uncategorized] ~268-~268: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...allowed header. - Config.ExposeHeaders: Now accepts a slice of strings, each re...

docs/middleware/cache.md Show resolved Hide resolved
docs/whats_new.md Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (2)
docs/middleware/cache.md (2)

65-73: Clarify the usage of CacheInvalidator function to enhance understanding.

The description of the CacheInvalidator function could be more detailed. Consider adding a sentence like: "Return true if conditions such as specific query parameters or headers are met, which require the cache to be invalidated."


Line range hint 55-55: Replace hard tabs with spaces for consistency.

55c55
-		CacheInvalidator: nil,
+    CacheInvalidator: nil,
99c99
-		CacheInvalidator: nil,
+    CacheInvalidator: nil,
101c101
-		CacheInvalidator: nil,
+    CacheInvalidator: nil,

Also applies to: 99-99, 101-101

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b26eb02 and 1485148.

Files selected for processing (1)
  • docs/middleware/cache.md (2 hunks)
Additional context used
Markdownlint
docs/middleware/cache.md

55-55: Column: 1 (MD010, no-hard-tabs)
Hard tabs


99-99: Column: 1 (MD010, no-hard-tabs)
Hard tabs


101-101: Column: 1 (MD010, no-hard-tabs)
Hard tabs

Additional comments not posted (1)
docs/middleware/cache.md (1)

83-83: Ensure the description of CacheInvalidator is clear and informative.

The provided description is succinct and clearly states the purpose of the function. However, consider adding practical examples or scenarios where this might be particularly useful to help users better understand when to use this feature.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1485148 and b75abf0.

Files selected for processing (1)
  • docs/middleware/cache.md (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • docs/middleware/cache.md

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
docs/middleware/cache.md (1)

83-83: Ensure the description of CacheInvalidator is comprehensive.

The description of CacheInvalidator is good but could be enhanced by specifying typical use cases or conditions under which cache invalidation might be necessary, such as changes in user session data or specific request headers.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b75abf0 and 2e20a93.

Files selected for processing (1)
  • docs/middleware/cache.md (1 hunks)
Additional context used
Markdownlint
docs/middleware/cache.md

55-55: Column: 1 (MD010, no-hard-tabs)
Hard tabs

Additional comments not posted (2)
docs/middleware/cache.md (2)

65-73: Clarify the description for CacheInvalidator.

The description of the CacheInvalidator function in the example could be more detailed. It is important to explain under what circumstances a user might want to return true to invalidate the cache. Consider adding a sentence like: "Return true if conditions such as specific query parameters or headers are met, which require the cache to be invalidated."


101-101: Replace hard tabs with spaces in Markdown files.

This is important for ensuring that the documentation renders correctly across different platforms and editors.

-    CacheInvalidator: nil,
+  CacheInvalidator: nil,

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2e20a93 and 3c6eff5.

Files selected for processing (1)
  • docs/middleware/cache.md (1 hunks)
Additional context used
Markdownlint
docs/middleware/cache.md

55-55: Column: 1 (MD010, no-hard-tabs)
Hard tabs


73-73: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines

docs/middleware/cache.md Show resolved Hide resolved
docs/middleware/cache.md Show resolved Hide resolved
docs/middleware/cache.md Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
docs/middleware/cache.md (1)

65-75: The example and description for the CacheInvalidator function are clear and informative. However, consider adding a brief explanation of the function's role within the cache flow in the initial introduction of the CacheInvalidator to provide a smoother learning curve for new users.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3c6eff5 and d56e1f9.

Files selected for processing (1)
  • docs/middleware/cache.md (1 hunks)
Additional context used
Learnings (1)
docs/middleware/cache.md (1)
User: hcancelik
PR: gofiber/fiber#3036
File: docs/middleware/cache.md:103-103
Timestamp: 2024-06-15T19:26:06.401Z
Learning: There are no hard tabs in the lines 100 to 105 of the `docs/middleware/cache.md` file. Future comments about formatting should accurately reflect the actual content.
Markdownlint
docs/middleware/cache.md

55-55: Column: 1 (MD010, no-hard-tabs)
Hard tabs

Additional comments not posted (2)
docs/middleware/cache.md (2)

85-85: The definition for CacheInvalidator is well-documented. It's clear how it functions and when it should return true. This aligns with the PR's objective to enhance cache management flexibility.


103-103: The default configuration setup in ConfigDefault is correctly updated to reflect the new CacheInvalidator functionality. This ensures that users are aware of the default behavior when they do not specify any configuration.

Copy link
Member

@gaby gaby left a comment

Choose a reason for hiding this comment

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

LGTM

@ReneWerner87 ReneWerner87 merged commit c9b7b1a into gofiber:main Jun 26, 2024
15 checks passed
Copy link

welcome bot commented Jun 26, 2024

Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@hcancelik hcancelik deleted the cache-invalidation branch June 26, 2024 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

🤗 [Question]: Cache Next is not called when KeyGenerator is Defined
3 participants