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 to API Resources #254

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

jacobtomlinson
Copy link
Member

@jacobtomlinson jacobtomlinson commented Dec 15, 2023

Closes #253
Xref #251

Calling kr8s.api_resources() can be an expensive operation, and kr8s.get() calls this under the hood every time. So this PR adds a cache to that call.

It looks like kubectl caches these requests to a file on disk for 10 minutes, which makes sense given that kubectl can't maintain an in-memory cache between separate CLI calls. I considered trying to reuse the cache that kubectl uses, but I feel that ties us too closely to a kubectl implementation detail.

Copy link

codecov bot commented Dec 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1a79d2c) 94.56% compared to head (50e69d6) 94.57%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #254      +/-   ##
==========================================
+ Coverage   94.56%   94.57%   +0.01%     
==========================================
  Files          27       27              
  Lines        2743     2749       +6     
==========================================
+ Hits         2594     2600       +6     
  Misses        149      149              

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

@jacobtomlinson jacobtomlinson merged commit 134647a into kr8s-org:main Dec 15, 2023
11 checks passed
@jacobtomlinson jacobtomlinson deleted the cache-api-resource branch December 15, 2023 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache calls to api_resources()
1 participant