Repository navigation
docs: correct complexity notes and behaviour details on the algorithms page - #119
Merged
Merged
Conversation
Owner
|
Thanks for the corrections.
You made a good point! I am fixing this issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I checked the "Choosing a Cache" page against the code and 6.2.9 and fixed what did not match:
ewas used without a definition.O(e+1)~instead ofO(e)~— an insert with nothing expired is O(1) (about 160–200 ns with 1k and with 100k live entries).getonly bumps the counter and the heap is repaired on the next eviction (lazyheap.rsrepair_root/apply_pending), so onepopitemafterkreads is O(k log n). Added a note, plus one on LFU/VTTL iteration re-sorting.get/[]treat expired entries as misses but do not remove them, andlen()/bool()count them until an insert, iteration,current_size()orexpire(). The tips link anchor was#ttlcachevttlcache-...; the page id is#ttlcache-vttlcache-background-thread.len(cache)printed 4, not 0, after the sleep; the example now callsexpire()first.LRUCache,getand[]invalidate open iterators; inLFUCache, a new iteration after a read does.Every changed snippet was run against 6.2.9, and
mkdocs buildrenders the page with the fixed link.One thing I left as is because I'm not sure which side is intended: the page says
TTLCacheevicts "FIFO among live entries". In the code, overwriting a key gives it a new expiry but keeps its place in the queue, so a refreshed live key can be evicted while an older expired one stays, andpopitem()onTTLCache/VTTLCachecan return an expired entry. Is that the intended behaviour (then I'll update the wording here), or should eviction/popitemdrop expired entries first?