Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: add ability to clear/cap cache size #31

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

tlambert03
Copy link
Member

@tlambert03 tlambert03 commented Jan 31, 2025

fixes #30

@aditya306b, let me know if this would work for you

New caching functionalities:

  • Added clear_api_cache function to clear all cached responses to the Iconify API from the current session in src/pyconify/api.py.
  • Added set_api_cache_maxsize function to set the lru_cache max size for all API calls and clear the cache in src/pyconify/api.py.

Updates to existing cache mechanisms:

  • Updated collections, collection, svg_path, and css functions to use functools.lru_cache with a default max size of 128 in src/pyconify/api.py. [1] [2] [3] [4]

Tests:

  • Added test_clear_api_cache to verify the functionality of the new cache-related functions in tests/test_pyconify.py.

Imports and type annotations:

  • Added Any, Protocol, and cast imports to support the new cache functionalities in src/pyconify/api.py. [1] [2]

Module exports:

  • Updated __init__.py to export the new clear_api_cache and set_api_cache_maxsize functions. [1] [2] [3]

Copy link

codecov bot commented Jan 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (82e5515) to head (b7c738d).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #31   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines          261       276   +15     
=========================================
+ Hits           261       276   +15     

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

@tlambert03 tlambert03 merged commit 1c27e48 into pyapp-kit:main Feb 6, 2025
15 checks passed
@tlambert03 tlambert03 deleted the cache-cap branch February 6, 2025 13:18
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FIX: Add Option to Disable Cache or Set TTL
2 participants