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

feat(response-cache): onTtl hook to manipulate the cached response #2392

Merged
merged 4 commits into from
Jan 27, 2025

Conversation

ardatan
Copy link
Collaborator

@ardatan ardatan commented Jan 27, 2025

onTtl hook allows to manipulate the calculated TTL

Copy link

changeset-bot bot commented Jan 27, 2025

🦋 Changeset detected

Latest commit: 0bbd97f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@envelop/response-cache Minor
@envelop/response-cache-cloudflare-kv Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Jan 27, 2025

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@envelop/response-cache 6.3.0-alpha-20250127143711-0bbd97f23b7944a2a75cd5073360438d4051483c npm ↗︎ unpkg ↗︎
@envelop/response-cache-cloudflare-kv 2.0.0-alpha-20250127143711-0bbd97f23b7944a2a75cd5073360438d4051483c npm ↗︎ unpkg ↗︎

@theguild-bot
Copy link
Collaborator

theguild-bot commented Jan 27, 2025

✅ Benchmark Results

     ✓ no_errors
     ✓ expected_result

     checks.............................................: 100.00% ✓ 867406      ✗ 0     
     ✓ { mode:envelop-cache-and-no-internal-tracing }...: 100.00% ✓ 210442      ✗ 0     
     ✓ { mode:envelop-cache-jit }.......................: 100.00% ✓ 339512      ✗ 0     
     ✓ { mode:envelop-just-cache }......................: 100.00% ✓ 205434      ✗ 0     
     ✓ { mode:graphql-js }..............................: 100.00% ✓ 112018      ✗ 0     
     data_received......................................: 3.3 GB  28 MB/s
     data_sent..........................................: 189 MB  1.6 MB/s
     envelop_init.......................................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-jit }.......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-just-cache }......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:graphql-js }..............................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     envelop_total......................................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-jit }.......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-just-cache }......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:graphql-js }..............................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     event_loop_lag.....................................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-and-no-internal-tracing }...: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-jit }.......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-just-cache }......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:graphql-js }..............................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     graphql_context....................................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-jit }.......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-just-cache }......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:graphql-js }..............................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     graphql_execute....................................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-jit }.......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-just-cache }......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:graphql-js }..............................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     graphql_parse......................................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-jit }.......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-just-cache }......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:graphql-js }..............................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     graphql_validate...................................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-jit }.......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-just-cache }......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:graphql-js }..............................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     http_req_blocked...................................: avg=2.94µs  min=1.19µs   med=2.54µs  max=6.25ms  p(90)=3.47µs  p(95)=3.81µs 
     http_req_connecting................................: avg=19ns    min=0s       med=0s      max=1.01ms  p(90)=0s      p(95)=0s     
     http_req_duration..................................: avg=2.47ms  min=173.48µs med=2.16ms  max=89.78ms p(90)=4.54ms  p(95)=5.01ms 
       { expected_response:true }.......................: avg=2.47ms  min=173.48µs med=2.16ms  max=89.78ms p(90)=4.54ms  p(95)=5.01ms 
     ✓ { mode:envelop-cache-and-no-internal-tracing }...: avg=2.56ms  min=389.33µs med=2.28ms  max=16.76ms p(90)=4.47ms  p(95)=4.84ms 
     ✓ { mode:envelop-cache-jit }.......................: avg=1.45ms  min=173.48µs med=1.2ms   max=12.2ms  p(90)=2.43ms  p(95)=2.58ms 
     ✓ { mode:envelop-just-cache }......................: avg=2.63ms  min=428.82µs med=2.32ms  max=35.05ms p(90)=4.54ms  p(95)=4.9ms  
     ✓ { mode:graphql-js }..............................: avg=5.07ms  min=975.03µs med=4.38ms  max=89.78ms p(90)=8.5ms   p(95)=9.21ms 
     http_req_failed....................................: 0.00%   ✓ 0           ✗ 433703
     http_req_receiving.................................: avg=33.99µs min=13.28µs  med=29.49µs max=7.53ms  p(90)=45.18µs p(95)=49.9µs 
     http_req_sending...................................: avg=12µs    min=3.64µs   med=9.79µs  max=11.68ms p(90)=14.11µs p(95)=18.14µs
     http_req_tls_handshaking...........................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     http_req_waiting...................................: avg=2.42ms  min=139.15µs med=2.11ms  max=89.71ms p(90)=4.49ms  p(95)=4.95ms 
     http_reqs..........................................: 433703  3614.116547/s
     iteration_duration.................................: avg=2.75ms  min=361.91µs med=2.43ms  max=90.37ms p(90)=4.82ms  p(95)=5.3ms  
     iterations.........................................: 433703  3614.116547/s
     vus................................................: 10      min=10        max=10  
     vus_max............................................: 20      min=20        max=20  

Copy link
Contributor

github-actions bot commented Jan 27, 2025

💻 Website Preview

The latest changes are available as preview in: https://a696e129.envelop.pages.dev

@EmrysMyrddin
Copy link
Collaborator

Perhaps add some documentation and a usage example in the changelog ?

@ardatan
Copy link
Collaborator Author

ardatan commented Jan 27, 2025

@EmrysMyrddin Not sure what to document as the only use case I see is ours in the gateway

@ardatan ardatan merged commit 7882ffb into main Jan 27, 2025
13 checks passed
@EmrysMyrddin
Copy link
Collaborator

Just add its description to the readme :-) so that the documentation. Stays as complete as possible without having to dig though the types.

@ardatan
Copy link
Collaborator Author

ardatan commented Jan 27, 2025

@EmrysMyrddin Let me know if it looks good
#2394

@ardatan ardatan deleted the on-ttl branch January 27, 2025 15:44
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.

3 participants