Skip to content

Commit

Permalink
feat(utils): defer updating stale cache with utils.get_cached_data
Browse files Browse the repository at this point in the history
Signed-off-by: Braden Mars <bradenmars@bradenmars.me>
  • Loading branch information
BradenM committed Dec 11, 2022
1 parent dbeb0a9 commit afd2ba5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions micropy/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
used by MicropyCli
"""

from __future__ import annotations

import inspect
import io
import os
Expand All @@ -27,6 +29,8 @@
from requests import utils as requtil
from tqdm import tqdm

from .types import PathStr

__all__ = [
"is_url",
"get_url_filename",
Expand All @@ -46,8 +50,6 @@
"get_class_that_defined_method",
]

from .types import PathStr


def is_url(url):
"""Check if provided string is a url.
Expand Down Expand Up @@ -402,7 +404,7 @@ def is_update_available():
return False


@cachier(stale_after=timedelta(days=3))
@cachier(stale_after=timedelta(days=3), next_time=True)
def get_cached_data(url):
"""Wrap requests with a short cache."""
source_data = requests.get(url).json()
Expand Down

0 comments on commit afd2ba5

Please sign in to comment.