How to use the cachetools.func.ttl_cache function in cachetools

To help you get started, we’ve selected a few cachetools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github quay / quay / data / model / repository.py View on Github external
@ttl_cache(maxsize=1, ttl=600)
def _get_gc_expiration_policies():
    policy_tuples_query = (
        Namespace.select(Namespace.removed_tag_expiration_s)
        .distinct()
        .limit(100)  # This sucks but it's the only way to limit memory
        .tuples()
    )
    return [policy[0] for policy in policy_tuples_query]
github n0madic / gitlab-registry-images-cleaner / gricleaner.py View on Github external
    @cachetools.func.ttl_cache(maxsize=100, ttl=10 * 60)
    def get_bearer(self, scope):
        """Return bearer token from Gitlab jwt"""
        url = "{}/?service=container_registry&scope={}:*".format(self.jwt, scope)
        response = requests.get(url, auth=self.auth, verify=self.requests_verify)
        response.raise_for_status()
        token = response.json()
        return token["token"]
github SBRG / ssbio / ssbio / organisms / ecoli.py View on Github external
@cachetools.func.ttl_cache(maxsize=500)
def get_folding_rate_for_gene(bnumber, temp, refT=37):
    """Predict the kinetic folding rate of a protein at temperature T

    Args:
        bnumber:  E. coli locus ID
        temp: temperature
        refT: reference temperature default to 37C

    Returns:
        kinetic folding rate kf (kegg-1)

    """

    slope = 22000  # not many data on this value, but it's effect on growth rate very small
    id_and_seq = uniprot_info(bnumber)
github wimglenn / johnnydep / johnnydep / lib.py View on Github external
@ttl_cache(maxsize=512, ttl=60 * 5)
def _get_info(dist_name, index_url=None, env=None, extra_index_url=None):
    log = logger.bind(dist_name=dist_name)
    tmpdir = tempfile.mkdtemp()
    log.debug("created scratch", tmpdir=tmpdir)
    try:
        with wimpy.working_directory(tmpdir):
            data = pipper.get(
                dist_name,
                index_url=index_url,
                env=env,
                extra_index_url=extra_index_url,
                tmpdir=".",
            )
        dist_path = data["path"]
        # extract any info we may need from downloaded dist right now, so the
        # downloaded file can be cleaned up immediately
github raiden-network / raiden / tools / scenario-player / scenario_player / node_support.py View on Github external
    @ttl_cache(maxsize=1, ttl=600)
    def _latest_release_name(self):
        latest_release_file_name = self._expand_release_template(
            RAIDEN_RELEASES_LATEST_FILE_TEMPLATE
        )
        url = urljoin(RAIDEN_RELEASES_URL, latest_release_file_name)
        log.debug("Fetching latest Raiden release", lookup_url=url)
        return requests.get(url).text.strip()