Skip to content

docs-server: Fix _TTLCache LRU and add separate search cache TTL#181

Merged
cbjuan merged 2 commits intomainfrom
feat/171-fix-cache-lru-and-search-ttl
Apr 16, 2026
Merged

docs-server: Fix _TTLCache LRU and add separate search cache TTL#181
cbjuan merged 2 commits intomainfrom
feat/171-fix-cache-lru-and-search-ttl

Conversation

@cbjuan
Copy link
Copy Markdown
Member

@cbjuan cbjuan commented Apr 15, 2026

Summary

  • Replace FIFO eviction with actual LRU using OrderedDict (move_to_end on get, popitem(last=False) for O(1) eviction)
  • Add SEARCH_CACHE_TTL env var (default 5min) for search/JSON cache, separate from page cache (1hr)
  • Add tests for LRU eviction order, cache key updates, and SEARCH_CACHE_TTL default

Closes #171

Replace FIFO eviction with actual LRU using OrderedDict (move_to_end on get, popitem(last=False) for O(1) eviction). Add SEARCH_CACHE_TTL
(5min default) for JSON/search cache separate from page cache (1hr).

Closes #171

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cbjuan cbjuan requested a review from vabarbosa as a code owner April 15, 2026 21:52
Copy link
Copy Markdown
Collaborator

@vabarbosa vabarbosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you. just one minor comment about documenting the env variable

# HTTP timeout configuration (in seconds)
HTTP_TIMEOUT = _get_env_float("QISKIT_HTTP_TIMEOUT", 10.0)
CACHE_TTL = _get_env_float("QISKIT_DOCS_CACHE_TTL", 3600.0)
SEARCH_CACHE_TTL = _get_env_float("QISKIT_SEARCH_CACHE_TTL", 300.0) # 5 min default
Copy link
Copy Markdown
Collaborator

@vabarbosa vabarbosa Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should QISKIT_SEARCH_CACHE_TTL is be documented in the README?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thanks!

@cbjuan cbjuan merged commit fcb3c55 into main Apr 16, 2026
30 checks passed
@cbjuan cbjuan deleted the feat/171-fix-cache-lru-and-search-ttl branch April 16, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs-server: Fix _TTLCache -- claims LRU but implements FIFO, and add separate search cache TTL

2 participants