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 force_cache extension #117

Merged
merged 4 commits into from
Nov 29, 2023
Merged

Add force_cache extension #117

merged 4 commits into from
Nov 29, 2023

Conversation

karpetrosyan
Copy link
Owner

@karpetrosyan karpetrosyan commented Nov 28, 2023

Ref: #116

This pull request adds the force_cache extension, which can be included in the request to tell the controller that for this particular request you want to disable all the caching rules, enforcing the client to always cache that response.

This can be useful when you just want to cache the response for some time, using the power of Hishel's storage, whatever response is cacheable or not.

Example:

import hishel

client = hishel.CacheClient(storage=hishel.SQLiteStorage(ttl=3600))
response = client.get("https://www.example.com/uncachable-endpoint", extensions={"ignore_rules": True})

@karpetrosyan karpetrosyan added the enhancement New feature or request label Nov 28, 2023
Copy link

codecov bot commented Nov 28, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (dd33b20) 100.00% compared to head (d34179a) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #117   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines         1747      1769   +22     
=========================================
+ Hits          1747      1769   +22     

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

Copy link
Collaborator

@parkerhancock parkerhancock left a comment

Choose a reason for hiding this comment

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

Hey! Running this by you before I merge. Code looks great, no functional changes. But I think it would be clearer what this is doing if we call it "force_cache" rather than "ignore_rules," since it isn't clear what rules we are ignoring. Let me know if you object to that, otherwise this is good to go!

@karpetrosyan
Copy link
Owner Author

Hey @parkerhancock! Yes, force_cache makes more sense, thank you!

I guess we are ready to merge this

@karpetrosyan karpetrosyan changed the title Add ignore-rules extension Add force_cache extension Nov 29, 2023
@karpetrosyan karpetrosyan merged commit 34231cc into master Nov 29, 2023
7 checks passed
@karpetrosyan karpetrosyan mentioned this pull request Nov 30, 2023
@karpetrosyan karpetrosyan deleted the add-always-cache-extension branch December 1, 2023 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants