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

Implement API key caching and update documentation #242

Closed

Conversation

AlexIvanchyk
Copy link

#173

  • Introduced API key caching using the CacheMixin class to improve performance.
  • Added cache checks before querying the database for API key validity.
  • Connected post-save and post-delete signals to AbstractAPIKey descendants to manage cache invalidation.
  • Included tests for the new caching mechanism.
  • Updated 'docs/guide.md' with API key caching instructions.

- Introduced API key caching using the CacheMixin class to improve performance.
- Added cache checks before querying the database for API key validity.
- Connected post-save and post-delete signals to AbstractAPIKey descendants to manage cache invalidation.
- Included tests for the new caching mechanism.
- Updated 'docs/guide.md' with API key caching instructions.
@codecov-commenter
Copy link

codecov-commenter commented Aug 17, 2023

Codecov Report

Merging #242 (26ea131) into master (13fe987) will not change coverage.
The diff coverage is 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the GitHub App Integration for your organization. Read more.

@@            Coverage Diff             @@
##            master      #242    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           24        27     +3     
  Lines          593       718   +125     
==========================================
+ Hits           593       718   +125     
Files Changed Coverage Δ
src/rest_framework_api_key/apps.py 100.00% <100.00%> (ø)
src/rest_framework_api_key/mixins.py 100.00% <100.00%> (ø)
src/rest_framework_api_key/permissions.py 100.00% <100.00%> (ø)
src/rest_framework_api_key/signals.py 100.00% <100.00%> (ø)
tests/test_caching.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

- Introduced API key caching using the CacheMixin class to improve performance.
- Added cache checks before querying the database for API key validity.
- Connected post-save and post-delete signals to AbstractAPIKey descendants to manage cache invalidation.
- Included tests for the new caching mechanism.
- Updated 'docs/guide.md' with API key caching instructions.
- Provide an optional setting for caching, letting users with stringent security concerns disable this feature as needed.
- Introduced a new test case where an exception is raised if  CacheMixin is used when no model is defined. This ensures that a useful error message is displayed if a developer forgets to set the model attribute when using CacheMixin.
- Added a new test case to ensure that cache invalidation is properly implemented. This tests the invalidate_cache function of CacheMixin to ensure it is effectively removing the corresponding cache entry as needed.
@florimondmanca
Copy link
Owner

Hi @AlexIvanchyk,

Given that we went with SHA512 hashing via #244, I will kindly close this pull request.

I want to express many thanks for moving the issue forward and discussing ideas as well as this implementation PR. I'm sure this will be of useful reference if caching is brought up in the future.

Cheers!

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