fgof-cache Public
Go to file
T
Code
Use Git or checkout with SVN using the web URL.
No matching headings.
fgof-cache
Disk cache helpers for modern Fortran.
fgof-cache is intended to be a small, standalone library for cache
directories, cache entries, and repeatable on-disk storage flows that CLI tools
and local developer tooling keep hand-rolling.
It is part of the FortranGoingOnForty lib-modules
catalog, but it is intended to stand on its own as a normal fpm package.
Current v1 target:
- stable cache option, root, and entry types
- predictable cache-root resolution and initialization
- explicit cache key and path helpers
- safe write-through and cleanup semantics built on
fgof-temp
Future scope:
- richer invalidation policies and size-budget pruning
- metadata-aware cache indexes
- binary payload helpers and more entry formats
Status
Sprint 04 is in place.
Tracked today:
- explicit cache root resolution with namespace support
- on-demand cache root initialization on POSIX backends
- deterministic key token and key-to-path helpers
- text-focused cache entry write, read, and remove helpers
- entry resolution helpers that expose root, relative path, presence state, and file metadata
- deterministic stale checks with optional explicit reference times
- namespace-aware stale-entry pruning helpers
- tracked round-trip and prune examples
fgof-temp-backed write-through safety for cache writes- focused coverage in
fpm test - CI on macOS and Ubuntu, including direct example execution
Why Use It
- cache logic shows up in tools, build helpers, editors, and local services
- most projects still re-solve naming, layout, and cleanup rules themselves
- a focused cache library can build naturally on the released temp and fs layers
Public API Shape
Primary modules:
fgof_cachefgof_cache_types
Public types:
cache_optionscache_rootcache_entrycache_prune_resultcache_text_result
Public constants:
FGOF_CACHE_OKFGOF_CACHE_ERR_INVALID_OPTIONSFGOF_CACHE_ERR_NOT_FOUNDFGOF_CACHE_ERR_IOFGOF_CACHE_ERR_INTERNAL
Current public procedures:
clear_cache_optionsclear_cache_rootclear_cache_entryclear_cache_prune_resultensure_cache_rootcache_key_tokencache_relative_path_for_keycache_path_for_keyresolve_cache_entrycache_entry_is_staleclear_cache_text_resultprune_stale_cachewrite_cache_textread_cache_textremove_cache_entrycache_backend_namecache_error_name
Current semantics:
ensure_cache_root()resolves roots from explicitroot_dir, or fromXDG_CACHE_HOME/HOMEwhenroot_diris absent- explicit
namespacevalues are appended as a subdirectory and validated up front create_root=.true.creates cache directories on demand;create_root=.false.requires the root to already existcache_key_token()maps the exact Fortran character payload to a lowercase hex tokencache_relative_path_for_key()shards tokens into a stableaa/bb/fulltokenlayoutresolve_cache_entry()gives callers the resolved root path, relative path, full path, current presence state, and metadata for stored entriescache_entry_is_stale()lets callers make deterministic TTL-style decisions, with an optional explicit reference time for tests and batch logicwrite_cache_text()creates sharded parent directories as needed and writes throughfgof-tempatomic replacementread_cache_text()reads exact stored Fortran character payloads back out of cache entriesread_cache_text()andremove_cache_entry()do not create missing cache roots as a side effectremove_cache_entry()removes stored cache files by key while leaving the cache root in place- successful removals clear cached metadata on the returned entry
- non-file entry paths are rejected instead of being treated as normal cache files
prune_stale_cache()prunes only the resolved namespace root, requiresnamespacewhen pruning an explicitroot_dir, treats missing roots as a no-op, and removes emptied shard directories as it goes
Build And Test
fpm test
That is the baseline verification command locally and in CI.
Tracked examples:
Supported Platforms
- macOS
- Linux
Boundaries
- intended to stay independently versioned and releasable
- focused on cache ergonomics, not full database or state management
- should stay useful on its own even if future state-oriented packages build on top
License
MIT