You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Limit the lifetime and size of the KGClient caches #168
Since #167, all of fairgraph's caching is done by the KGClient:
KGClient.cache, the JSON-LD documents of instances;
the existence cache, the ids found by, or created after, existence queries;
_query_cache, stored query definitions.
Each of these lasts as long as the client, and grows without limit (point 10 in #80).
That's fine for a client that only lives for one script run or one web request. But some clients live much longer: for example, service-account clients in web services, which are typically created once and kept for the life of the process, or long notebook sessions. For these:
The caches grow without limit.
Entries can be stale. A cached document is never refreshed unless the instance is changed through the same client, so changes made by others, or through another client in the same process, aren't seen.
Possible approaches, which could be combined:
A maximum age (TTL) for cache entries, set in the KGClient constructor. This suits the existence cache especially well: it only needs to cover the delay before a new instance appears in query results, which is seconds or minutes.
A maximum size, e.g. least-recently-used eviction.
A public clear_cache() method, for applications that want to control this themselves, e.g. clearing a service client's caches at the start of each request.
Activity