Documentation
¶
Overview ¶
Package cache resolves a safe, OS-appropriate wazero compilation-cache directory for go-googlesql.
go-googlesql ships a ~13 MB wasm module that costs roughly 3 s to compile to native code in CompilationModeCompiler. With a warm cache pointed at a stable on-disk directory, subsequent processes drop their Init() time to ~0.6 s. This package picks that directory using os.UserCacheDir conventions, isolates the cache per linked go-googlesql module version (so a dependency upgrade doesn't try to load stale precompiled wasm), and refuses to write anywhere that could indicate a TOCTOU attack.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Default ¶
Default returns the canonical wazero cache directory for the current user. The path is keyed by the linked go-googlesql module version so an upgrade gets a fresh cache.
macOS: ~/Library/Caches/go-googlesql-executequery/wazero/<ver>
Linux: $XDG_CACHE_HOME/go-googlesql-executequery/wazero/<ver>
(~/.cache/... when XDG_CACHE_HOME is unset)
Windows: %LocalAppData%/go-googlesql-executequery/wazero/<ver>
func EnsureSafe ¶
EnsureSafe creates dir (mode 0700) if missing, and refuses to use it if it already exists but is not a regular directory or is a symlink whose target lies outside the user cache root.
Returns the canonical (symlink-resolved) directory on success.
Types ¶
type Option ¶
type Option func(*setupOptions)
Option configures Setup.
func Disable ¶
func Disable() Option
Disable suppresses the on-disk cache. googlesql.Init is still called, in CompilationModeInterpreter (no native compile happens, so no cache is needed).
func WithCompilationMode ¶
func WithCompilationMode(mode googlesql.CompilationMode) Option
WithCompilationMode lets callers override the compilation mode. Default is CompilationModeCompiler.