pyEuropePMC

Caching skill

Cache the API responses of a client so that repeated calls do not send new requests. The full guide is Caching.

from pyeuropepmc import CacheConfig, SearchClient

cache_config = CacheConfig(enabled=True, ttl=3600)  # entries expire after one hour

with SearchClient(cache_config=cache_config) as client:
    client.search("cancer", pageSize=10)
    client.search("cancer", pageSize=10)  # answered from the cache
    stats = client.get_cache_stats()
    print(stats["hits"], stats["misses"])  # 1 1

Key tips: