Repository navigation
Conversation
expire.Wrap(cache, ttl) puts a clock in front of any evict.Cache that holds expire.Entry values, and SetWithTTL gives one entry a time of its own. An expired entry is a miss for Get, Peek, GetMany, Delete and All, but stays until it is evicted, set again, deleted or cleared; Set hands it back like any entry. Readers look at a copy of the time that one shared timer updates every 10 ms, and at the time itself only within 50 ms of a deadline, so an entry is never a miss early and is found late only if the timer runs more than 40 ms late. On an Apple M3 Max with tinylfu, a Get that hits took 15% longer on one CPU and 11-13% on eight, and a Set 17 ns longer. The read path stays free of calls through a generic wrapper: expired is at inline cost 79, and inlinecheck has probes for it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sizes in bytes, a loader, cleanup of expired entries and overwrites that scale, each pointing to otter. The note that a wrapper could count bytes from what Set and Delete hand back is gone: through expire, Delete hands back nothing for an expired entry, so the count would drift. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
For v0.3.0.
expire.expire.Wrap(cache, ttl)gives the entries of anyevict.Cachea time to live, andSetWithTTLone per entry.Get,Peek,GetMany,DeleteandAll, but stays until it is evicted, set again, deleted or cleared.tinylfu, aGetthat hits took 11–15% longer and aSet17 ns longer.statsandexpirestay separate.stats.Cachehas noSetWithTTL; the package doc says so.Checked:
golangci-lint run ./...finds nothing, andgo test ./...passes on darwin/arm64 and under Rosetta for the inline checks. linux/386 vets and compiles; this PR's CI is its first run.🤖 Generated with Claude Code