Documentation
¶
Overview ¶
Package cache is the local, NON-versioned index at .spectackle/cache/index.db (pure-Go SQLite via modernc.org/sqlite, FTS5). The versioned .spectackle files are the source of truth; the cache is rebuildable at any time. There are no migrations: a generation-stamp mismatch drops everything and rebuilds (the sync engine re-feeds it from disk).
v0 scope: meta, file stats and the FTS5 docs table. Graph persistence (nodes/edges/parse blobs) joins when the M1 indexer lands.
Index ¶
- type Cache
- func (c *Cache) Close() error
- func (c *Cache) FileStat(path string) (mtime, size int64, sha string, ok bool)
- func (c *Cache) List(kinds []string, k int) ([]Doc, error)
- func (c *Cache) PutFileStat(path string, mtime, size int64, sha string) error
- func (c *Cache) ReplaceDocs(dir string, kinds []string, docs []Doc) error
- func (c *Cache) Search(q string, kinds []string, k int) ([]Doc, error)
- type Doc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache wraps the SQLite handle.
func Open ¶
Open opens (or rebuilds) the cache under the given cache directory. WAL + busy_timeout + immediate transactions: two agent processes rooted at the same workspace share this file and must not trip over each other.
func (*Cache) FileStat ¶
FileStat returns what the cache recorded for a path the last time it was indexed: the cheap metadata gate (mtime, size) plus the hash of the content those docs were actually built from. An empty sha means the content is unknown and the metadata alone must not be trusted.
func (*Cache) List ¶ added in v0.8.2
List enumerates docs of the given kinds with no query at all, in a stable descending-ID order — chronological for the time-ordered ID kinds, see the ORDER BY comment below. Search returns (nil, nil) for an empty query, which the find tool rendered as `ok no matches` — a successful call carrying a false answer on a workspace that had 96 rules (B-01KYR01E2VFEF). Enumeration is a separate question from matching, so it gets a separate query rather than a magic query string: there is no FTS MATCH here, only a kind filter.
func (*Cache) PutFileStat ¶
PutFileStat records a path's stat together with the content hash that was indexed from it. Pass the hash the docs were derived from, never a hash of some later read: the pair is what makes freshness follow content instead of metadata a same-size, timestamp-preserving write leaves untouched.
func (*Cache) ReplaceDocs ¶
ReplaceDocs atomically replaces all docs of the given kinds within one context dir — the FTS5-has-no-PK maintenance strategy: one changed file re-feeds all its record kinds.