mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
fix(cache): skip embeddings in the response cache
Embeddings responses are large and rarely repeat. Each one was stored for the cache TTL in the shared Redis. A burst of them raised memory on the shared Dragonfly to its limit. The cache now skips /v1/embeddings unless cache.cacheEmbeddings is true. The default is false. Chat caching does not change.
This commit is contained in:
@@ -115,7 +115,9 @@ func buildResponseCache(cc CacheConfig, client *respClient, logf, warnf, errorf
|
||||
logf("cache: enabled but redis is not configured; response caching disabled")
|
||||
return nil, nil
|
||||
}
|
||||
return newResponseCache(client, ttl, maxBody, logf, errorf), nil
|
||||
c := newResponseCache(client, ttl, maxBody, logf, errorf)
|
||||
c.embeddings = cc.CacheEmbeddings
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// groupCacheEnabled resolves whether grp's requests are cacheable, given
|
||||
@@ -229,6 +231,7 @@ type responseCache struct {
|
||||
lastFailure time.Time
|
||||
ttl time.Duration
|
||||
maxBodyBytes int
|
||||
embeddings bool // CacheConfig.CacheEmbeddings
|
||||
logMu sync.Mutex
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user