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’s pushed_at timestamp – 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 (None is 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 and cachedir.

ident

Identity string namespacing all entries, derived from the connection’s token and API URL (ident).

get_meta(key)[source]

Return a stored metadata value, or MISS.

set_meta(key, value)[source]

Store a metadata value.

get_file(owner, repo, path, pushed_at)[source]

Return a repository file’s stored content (which is None for cached negative lookups), or MISS when there is no entry or the stored entry does not match pushed_at.

set_file(owner, repo, path, content, pushed_at)[source]

Store a repository file’s content (None for a negative lookup) under the repository’s current pushed_at. Entries stored for a different pushed_at are discarded.

flush_repo(owner, repo)[source]

Drop all stored file contents of one repository.