1 Commits
Author SHA1 Message Date
clawbot 89d7055382 Remove the unused cache lifetime setting (closes #69)
check / check (push) Successful in 17m41s
CacheConfig.CacheTTL was set to DefaultCacheTTL (24 hours) and never
read, so cached images never expired. Remove the field, the constant
and the line that set it. Cached source and transformed images stay
until eviction removes them to keep the cache within cache_max_bytes.

A new test caches a source and a transformed image, sets back two days
fetched_at in source_metadata and source_content, created_at in
variant_content, the fetched_at in the source's metadata file, the
created_at in the .meta file, and the access and modification times of
those two files and of the two image files, and checks that both are
still served from the cache without a new upstream fetch.

Existing tests lose only the CacheTTL line of their cache config.

Model: opus-5-5
2026-10-13 03:58:40 +00:00
+14 -16
View File
@@ -434,21 +434,21 @@ func TestService_Get_Caching(t *testing.T) {
// TestService_Get_ServesSourceAndVariantCachedTwoDaysAgo caches a source and // TestService_Get_ServesSourceAndVariantCachedTwoDaysAgo caches a source and
// a variant of it and sets back two days every time pixa stored for them. // a variant of it and sets back two days every time pixa stored for them.
// For the source: fetched_at in source_metadata, fetched_at and // For the source: fetched_at in source_metadata and in source_content, the
// last_accessed_at in source_content, the fetched_at in its metadata file, // fetched_at in its metadata file, and the access and modification times of
// and the access and modification times of its file and of its metadata // its file and of its metadata file. For the variant: created_at in
// file. For the variant: created_at and last_accessed_at in variant_content, // variant_content, the created_at in its .meta file, and the access and
// the created_at in its .meta file, and the access and modification times of // modification times of its file and of its .meta file. It then checks that
// its file and of its .meta file. It then checks that the variant is still // the variant is still served from the cache and that a new variant is made
// served from the cache and that a new variant is made from the cached source // from the cached source without fetching it again.
// without fetching it again.
// //
// Left at the present: the files' status change and birth times, which a // Left at the present: last_accessed_at in source_content and variant_content,
// program cannot set, and the times of the directories holding the files, // which is when eviction last saw the entry used, not when it was cached; the
// which other entries share. The source's stored response headers are empty, // files' status change and birth times, which a program cannot set; and the
// as the mock fetcher sends none. expires_at, etag and last_modified in // times of the directories holding the files, which other entries share. The
// source_metadata and in the metadata file are never written, nor are the // source's stored response headers are empty, as the mock fetcher sends none.
// request_cache and output_content tables. // expires_at, etag and last_modified in source_metadata and in the metadata
// file are never written, nor are the request_cache and output_content tables.
func TestService_Get_ServesSourceAndVariantCachedTwoDaysAgo(t *testing.T) { func TestService_Get_ServesSourceAndVariantCachedTwoDaysAgo(t *testing.T) {
t.Parallel() t.Parallel()
@@ -522,7 +522,6 @@ func backdateSource(
updateOneRow(t, cache, updateOneRow(t, cache,
`UPDATE source_content SET fetched_at = ? WHERE content_hash = ?`, `UPDATE source_content SET fetched_at = ? WHERE content_hash = ?`,
dbTime, meta.ContentHash) dbTime, meta.ContentHash)
setSourceLastAccessed(t, cache, ContentHash(meta.ContentHash), when)
for _, path := range []string{ for _, path := range []string{
cache.srcContent.hashToPath(ContentHash(meta.ContentHash)), cache.srcContent.hashToPath(ContentHash(meta.ContentHash)),
@@ -572,7 +571,6 @@ func backdateVariant(
updateOneRow(t, cache, updateOneRow(t, cache,
`UPDATE variant_content SET created_at = ? WHERE cache_key = ?`, `UPDATE variant_content SET created_at = ? WHERE cache_key = ?`,
when.UTC().Format(sqliteTimestampFormat), string(key)) when.UTC().Format(sqliteTimestampFormat), string(key))
setVariantLastAccessed(t, cache, key, when)
for _, file := range []string{path, path + variantMetaSuffix} { for _, file := range []string{path, path + variantMetaSuffix} {
err = os.Chtimes(file, when, when) err = os.Chtimes(file, when, when)