summaryrefslogtreecommitdiff
path: root/internal/hexaicli/cache.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/hexaicli/cache.go')
-rw-r--r--internal/hexaicli/cache.go11
1 files changed, 3 insertions, 8 deletions
diff --git a/internal/hexaicli/cache.go b/internal/hexaicli/cache.go
index 742ffce..127c7f4 100644
--- a/internal/hexaicli/cache.go
+++ b/internal/hexaicli/cache.go
@@ -17,17 +17,12 @@ const cliResponseCacheTTL = 24 * time.Hour
// responseCache carries the injectable dependencies for the on-disk CLI
// response cache. The only dependency is the clock used to stamp entries and
-// decide expiry. Production code uses defaultResponseCache (backed by
-// time.Now); tests construct a responseCache with a fake clock to exercise TTL
-// expiry without sleeping.
+// decide expiry. Production wrappers construct it with time.Now; tests can use
+// a fake clock to exercise TTL expiry without sleeping.
type responseCache struct {
now func() time.Time
}
-// defaultResponseCache is the production cache used by the package-level
-// lookup/store wrappers. It reads the real wall clock.
-var defaultResponseCache = responseCache{now: time.Now}
-
// cacheNowContextKey carries an injected clock through the request context so
// the cache TTL logic can be driven deterministically (e.g. in tests) without
// mutating package state.
@@ -45,7 +40,7 @@ func responseCacheFromContext(ctx context.Context) responseCache {
if now, ok := ctx.Value(cacheNowContextKey{}).(func() time.Time); ok && now != nil {
return responseCache{now: now}
}
- return defaultResponseCache
+ return responseCache{now: time.Now}
}
type cliResponseCacheKey struct {