SQLite key-value store wrapper
Find a file
Claude b866dacdd2
feat(store): add TTL support and harden test coverage to 90.9%
Phase 0 -- Hardening:
- Fix SQLITE_BUSY under concurrent writes by setting SetMaxOpenConns(1)
  and PRAGMA busy_timeout=5000
- Add comprehensive tests: concurrent read/write (10 goroutines),
  edge cases (unicode, null bytes, SQL injection, long keys), error
  paths (closed store, invalid paths, corrupt files), group isolation,
  upsert verification, WAL mode verification, ErrNotFound wrapping
- Add benchmarks: Set, Get, GetAll (10K keys), file-backed Set

Phase 1 -- TTL Support:
- Add expires_at nullable column with schema migration for pre-TTL DBs
- SetWithTTL(group, key, value, duration) stores keys that auto-expire
- Lazy deletion on Get for expired keys
- Background purge goroutine (configurable interval, default 60s)
- Public PurgeExpired() method for manual cleanup
- Count, GetAll, Render all exclude expired entries
- Set clears TTL when overwriting a TTL key

Coverage: 73.1% -> 90.9% (48 tests, 0 races)

Co-Authored-By: Charon <developers@lethean.io>
2026-02-20 01:14:08 +00:00
CLAUDE.md feat(store): add TTL support and harden test coverage to 90.9% 2026-02-20 01:14:08 +00:00
FINDINGS.md feat(store): add TTL support and harden test coverage to 90.9% 2026-02-20 01:14:08 +00:00
go.mod fix: add modernc.org/sqlite dependency 2026-02-19 16:10:16 +00:00
go.sum fix: add modernc.org/sqlite dependency 2026-02-19 16:10:16 +00:00
store.go feat(store): add TTL support and harden test coverage to 90.9% 2026-02-20 01:14:08 +00:00
store_test.go feat(store): add TTL support and harden test coverage to 90.9% 2026-02-20 01:14:08 +00:00
TODO.md feat(store): add TTL support and harden test coverage to 90.9% 2026-02-20 01:14:08 +00:00