Skip to content

testocache: harden persistent cache and add namespaces#26

Merged
metafates merged 6 commits into
ozontech:mainfrom
dmedovich:feature/testocache-hardening
Jul 17, 2026
Merged

testocache: harden persistent cache and add namespaces#26
metafates merged 6 commits into
ozontech:mainfrom
dmedovich:feature/testocache-hardening

Conversation

@dmedovich

Copy link
Copy Markdown
Contributor

TL;DR

Closes #25

This PR hardens the file-backed cache behavior and adds scoped cache namespaces for plugins sharing the
same cache directory.

Changes

  • write cache entries through a temporary file followed by os.Rename;
  • validate the stored key before returning or removing an entry;
  • treat malformed and mismatched entries as missing;
  • ignore foreign and non-regular files in Keys;
  • preserve an existing .gitignore;
  • return ErrNotFound consistently for missing entries;
  • add testocache.Namespace for isolated keyspaces;
  • document the cache behavior and add regression tests.

The existing package-level API and FNV-based cache filenames remain compatible.

Testing

  • go test ./...
  • go test -race ./testocache
  • golangci-lint run --tests=false --timeout=5m
  • git diff --check

@metafates metafates left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, cool idea with the namespaces! Looks good overall, left some comments.

Also, thank you for the #23, will get it to a bit later

Comment thread testocache/cache.go Outdated
Comment thread testocache/cache.go
Comment thread testocache/cache.go Outdated
Comment thread testocache/cache_test.go
dmedovich and others added 2 commits July 16, 2026 21:51
metafates
metafates previously approved these changes Jul 17, 2026
metafates
metafates previously approved these changes Jul 17, 2026
@metafates

Copy link
Copy Markdown
Member

I've slightly improved atomic file writes and reused fnv hashing for namespaces instead of sha256

@metafates
metafates merged commit 9d9cea7 into ozontech:main Jul 17, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

testocache.Keys returns an empty key for a new cache

2 participants