module

Krikri::FactCache

Real Ansible's fact_caching support (ANSIBLE_CACHE_PLUGIN/ ANSIBLE_CACHE_PLUGIN_CONNECTION env vars - no ansible.cfg INI parsing exists in this engine, matching the established pattern elsewhere, e.g. ssh_manager.cr's own host_key_checking handling). Only the jsonfile backend is implemented - by far the most common real-world choice (the built-in default backend, memory, caches only within a single process and needs no support here at all, since @facts already IS that in-run cache; redis/memcached would need real client libraries this project doesn't carry).

Real Ansible only ever CONSULTS the cache under gathering: smart (or explicit + a play that skips gather_facts:) - gathering: implicit (the default) always re-gathers regardless of a configured cache, verified live against ansible-core 2.19.12: a warm fact-cache with default implicit gathering still re-ran setup.py every play. So this module is only ever consulted from the executor's existing @smart_gathering path (see gather_facts_for_all_hosts), never for implicit/explicit gathering - that mirrors real Ansible's own gating rather than reintroducing a second, independent on/off switch.

Constants

DEFAULT_TIMEOUT = 86400

Matches real Ansible's fact_caching_timeout default (24h, in seconds). 0 means never expire, same as real Ansible.

Class methods

enabled?
Source
read(host_name : String) : Hash(String, JSON::Any) | Nil

Returns the cached facts for host_name if the cache is enabled, a file exists, and it isn't older than the configured timeout - nil otherwise (cache miss, expired, disabled, or unreadable).

Source
write(host_name : String, facts : Hash(String, JSON::Any)) : Nil

Persists facts for host_name. Best-effort: a cache write failure (unwritable connection dir, disk full, ...) must never fail the play - real Ansible's own fact-cache writes are equally non-fatal.

Source