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 cache clearing and testing #10

Merged
merged 7 commits into from
Dec 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
simplify cache clearing
  • Loading branch information
mharoruiz committed Dec 18, 2024
commit af4729004872c1edf2ef040b9b1e47c36a2ad4c7
34 changes: 9 additions & 25 deletions src/imf_reader/sdr/clear_cache.py
Original file line number Diff line number Diff line change
@@ -8,32 +8,16 @@


def clear_cache():
"""Clear the cache for all lru_cache-decorated functions."""
"""Clear the cache for all lru_cache-decorated functions in the 3 sdr modules."""

cleared_caches = 0
# clear cache from read_announcements module
get_holdings_and_allocations_data.cache_clear()
get_latest_date.cache_clear()

# read_announcements
if (
get_holdings_and_allocations_data.cache_info().currsize > 0
or get_latest_date.cache_info().currsize > 0
):
get_holdings_and_allocations_data.cache_clear()
get_latest_date.cache_clear()
cleared_caches += 1
logger.info("Cache cleared - Holdings and allocations")
# clear cache from read_exchange_rate module
fetch_exchange_rates.cache_clear()

# read_exchange_rate
if fetch_exchange_rates.cache_info().currsize > 0:
fetch_exchange_rates.cache_clear()
cleared_caches += 1
logger.info("Cache cleared - Exchange rates")
# clear cache from read_interest_rate module
fetch_interest_rates.cache_clear()

# read_interest_rate
if fetch_interest_rates.cache_info().currsize > 0:
fetch_interest_rates.cache_clear()
cleared_caches += 1
logger.info("Cache cleared - Interest rates")

if cleared_caches == 0:

logger.info("Unable to clear cache - No cached data")
logger.info("Cache cleared")
Loading