apko
apko copied to clipboard
Use an LRU cache for indexes
For the index cache (which is always global currently), we don't set an upper bound as to how many indexes can be cached. That's likely benign in local cases but causes an arbitray amount of memory to be consumed if used as a service. This introduces an LRU cache instead, which can be configured using APKO_INDEX_CACHE_SIZE.
I think this also fixes a race in the existing implementation where we'd leak indexes with outdated etags if two HEAD requests would race outside of the critical section of adjusting the etag pointers.