Skip to content

Commit 67e7111

Browse files
rubysclaude
andcommitted
Fix out-of-memory error in cache initialization
Changed from AdapterWithCapacity (which expects number of entries) to AdapterWithStorageCapacity (which limits by bytes). This prevents OOM errors on memory-constrained environments like Fly.io containers. - Previous: 100000000 cache entries (interpreted as massive allocation) - Now: 10MB memory limit for cache storage 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e275bb0 commit 67e7111

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

internal/proxy/router.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ type Router struct {
3535

3636
// NewRouter creates a new chi router with all routes configured
3737
func NewRouter(cfg RouterConfig) *chi.Mux {
38-
// Initialize memory cache for static assets (100MB, 1 hour TTL)
38+
// Initialize memory cache for static assets (10MB max, LRU eviction)
3939
memcached, err := memory.NewAdapter(
4040
memory.AdapterWithAlgorithm(memory.LRU),
41-
memory.AdapterWithCapacity(100000000), // 100MB
41+
memory.AdapterWithStorageCapacity(10*1024*1024), // 10MB of memory
4242
)
4343
if err != nil {
4444
logger.WithField("error", err).Warn("Failed to initialize cache, proceeding without caching")

0 commit comments

Comments
 (0)