1 Commits
Author SHA1 Message Date
clawbot 5f9d624d74 Serve a cache hit with no database read or write (closes #309)
check / check (push) Waiting to run
A hit opens the variant file and nothing else: its content type comes
from the file's first bytes, and a file in no output format is a miss.
Its access time and count, and the access time of a cached source a
miss uses, go without waiting to one background goroutine that writes
them once a second; each kind of access time waits in a channel of
10,000 that drops the rest. Expired negative cache rows are left to
CleanExpired. The .meta files, metaCache, Lookup and golang-lru go,
with their tests; the two reconciliation walks, identical without the
.meta skip, share one. make bench runs a parallel cache hit benchmark
on the host, outside make check.

Model: opus-5-5
2026-10-21 18:12:55 +02:00
@@ -155,11 +155,12 @@ func TestService_Get_ReturnsByItsDeadlineWhileTheDatabaseIsBusy(t *testing.T) {
waitForCounters(t, svc.cache, cacheStatsCounters{missCount: 1})
}
// TestIncrementStats_ManyCountsPastTheirDeadlineLeaveOneWriteWaiting holds the
// database's one connection while many misses are counted past their
// deadline. At most one write may then wait for the connection, and every
// miss must reach the database once it is free.
func TestIncrementStats_ManyCountsPastTheirDeadlineLeaveOneWriteWaiting(t *testing.T) {
// TestIncrementStats_ManyCountsLeaveOneWriteWaiting holds the database's one
// connection while many misses are added to the pending counts, which the
// goroutine StartPendingCountWrites starts writes to the database. At most one
// write may then wait for the connection, and every miss must reach the
// database once it is free.
func TestIncrementStats_ManyCountsLeaveOneWriteWaiting(t *testing.T) {
t.Parallel()
cache, _ := newEvictionTestCache(t, 1<<30)
@@ -194,9 +195,9 @@ func TestIncrementStats_ManyCountsPastTheirDeadlineLeaveOneWriteWaiting(t *testi
waitForCounters(t, cache, cacheStatsCounters{missCount: misses})
}
// TestStats_IncludesPendingCounts counts hits and misses whose writes miss
// their deadline, and checks that Stats adds them to the database's counts
// before they are written.
// TestStats_IncludesPendingCounts adds hits and misses to the pending counts,
// with no goroutine started to write them, and checks that Stats adds them to
// the database's counts before they are written.
func TestStats_IncludesPendingCounts(t *testing.T) {
t.Parallel()