Low-level helpers operating on an coding_cache() object. All keys are
validated strictly against path traversal and unsafe characters; disk cache
writes are atomic and integrity-checked via SHA-256 checksums.
Arguments
- cache
An object of class
"llm_coding_cache".- key
Character cache key (typically produced by
cache_key()).- value
R object to store in the cache.
Value
cache_get()returns the cached object orNULLon a miss (or after gracefully evicting a corrupted disk entry).cache_set()invisibly returnsTRUEif written,FALSEif caching is disabled.cache_clear()invisibly returns the cache object.cache_stats()returns a named list withtype,dir,hits,misses,writes,evictions, andentries.
Examples
mc <- coding_cache("memory")
k <- cache_key("u1", "p1", "m1")
cache_set(mc, k, list(score = 4.5))
cache_get(mc, k)
#> $score
#> [1] 4.5
#>
cache_stats(mc)
#> $type
#> [1] "memory"
#>
#> $dir
#> NULL
#>
#> $hits
#> [1] 1
#>
#> $misses
#> [1] 0
#>
#> $writes
#> [1] 1
#>
#> $evictions
#> [1] 0
#>
#> $entries
#> [1] 1
#>
cache_clear(mc)
