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 caching #56

Merged
merged 5 commits into from
Dec 30, 2023
Merged

Add caching #56

merged 5 commits into from
Dec 30, 2023

Conversation

withinboredom
Copy link
Contributor

Closes #39

This adds some attributes for caching per component where the "highest score wins" type of algorithm. Basically private > public, max-age < no-cache < must-revalidate, etc.

src/Cache/Control/Tokenizer.php Dismissed Show dismissed Hide dismissed
Comment on lines +63 to +87
public function with(
int|null|false $maxAge = false,
int|null|false $sMaxAge = false,
bool|null $noCache = null,
bool|null $mustRevalidate = null,
bool|null $proxyRevalidate = null,
bool|null $noStore = null,
bool|null $public = null,
bool|null $immutable = null,
int|null|false $staleWhileRevalidating = false,
int|null|false $staleIfError = false,
): self {
return new self(
maxAge: $this->withInt($this->maxAge, $maxAge),
sMaxAge: $this->withInt($this->sMaxAge, $sMaxAge),
noCache: $this->withBool($this->noCache, $noCache),
mustRevalidate: $this->withBool($this->mustRevalidate, $mustRevalidate),
proxyRevalidate: $this->withBool($this->proxyRevalidate, $proxyRevalidate),
noStore: $this->withBool($this->noStore, $noStore),
public: $this->withBool($this->public, $public),
immutable: $this->withBool($this->immutable, $immutable),
staleWhileRevalidating: $this->withInt($this->staleWhileRevalidating, $staleWhileRevalidating),
staleIfError: $this->withInt($this->staleIfError, $staleIfError),
);
}

Check warning

Code scanning / PHPMD

Code Size Rules: ExcessiveParameterList Warning

The method with has 10 parameters. Consider reducing the number of parameters to less than 10.
src/Cache/Revalidate.php Dismissed Show dismissed Hide dismissed
Copy link

codecov bot commented Dec 30, 2023

Codecov Report

Attention: 24 lines in your changes are missing coverage. Please review.

Comparison is base (164b89d) 32.52% compared to head (05857be) 37.44%.

Files Patch % Lines
src/Hooks/Api/Invoker.php 0.00% 20 Missing ⚠️
src/Template/Parser/StreamingCompiler.php 50.00% 2 Missing ⚠️
src/Cache/NeverChanges.php 92.30% 1 Missing ⚠️
src/Cache/Revalidate.php 96.96% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main      #56      +/-   ##
============================================
+ Coverage     32.52%   37.44%   +4.91%     
- Complexity      538      570      +32     
============================================
  Files            51       50       -1     
  Lines          1823     1888      +65     
============================================
+ Hits            593      707     +114     
+ Misses         1230     1181      -49     

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

@withinboredom withinboredom merged commit c07f933 into main Dec 30, 2023
5 checks passed
@withinboredom withinboredom deleted the add-caching branch December 30, 2023 20:06
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.

Enable caching
1 participant