saltext.github.utils.gh.cache¶
Optional persistent cross-process cache for slow-changing GitHub API
data, backed by the minion’s salt.cache (cachedir).
Attached to every profile-resolved
GitHubConnection as its
store unless the profile opts out via cache. Particularly
useful for salt-call --local setups, where every invocation starts
a fresh process and the in-memory caches never survive.
Two kinds of data are stored, namespaced by a token/API URL-derived identity so rotated credentials or different endpoints never share entries:
Repository file contents (fetched for
resource:grains_files), validated against the repository’spushed_attimestamp – entries are served until the repository receives a new push. Negative lookups (missing files) are cached the same way.Metadata that is stable for a given token/owner: account types (organization vs user) and the token’s user login. These are stored indefinitely.
All storage errors degrade gracefully to cache misses.
- saltext.github.utils.gh.cache.MISS = <object object>¶
Sentinel for missing cache entries (
Noneis a valid cached value).
- class saltext.github.utils.gh.cache.PersistentCache(opts, ident)[source]¶
salt.cache-backed store, see the module docstring.- opts
The minion configuration (
__opts__), selecting the cache backend andcachedir.- ident
Identity string namespacing all entries, derived from the connection’s token and API URL (
ident).
- get_file(owner, repo, path, pushed_at)[source]¶
Return a repository file’s stored content (which is
Nonefor cached negative lookups), orMISSwhen there is no entry or the stored entry does not matchpushed_at.