Repository navigation
Fix insert_new not unwrapping %ConCache.Item{} - #86
Open
hikmetba-bit wants to merge 1 commit into
Open
hikmetba-bit wants to merge 1 commit into
hikmetba-bit wants to merge 1 commit into
Conversation
dirty_put has two clauses: one that matches %ConCache.Item{ttl:, value:}
and unwraps it into perform_put(cache, key, value, ttl), and a fallback
for a plain value that uses the cache's default ttl. dirty_insert_new
had no such split -- it stored whatever was passed straight into ETS,
so an %ConCache.Item{} ended up as the raw struct instead of its
.value, and its .ttl was silently ignored in favor of the cache
default.
Mirror dirty_put's two-clause pattern for dirty_insert_new via a new
perform_insert_new/4, so ConCache.Item behaves the same way for both
functions.
Fixes sasa1977#84.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
Fixes #84.
dirty_puthas two clauses: one that matches%ConCache.Item{ttl:, value:}and unwraps it intoperform_put(cache, key, value, ttl), and a fallback for a plain value that uses the cache's default ttl.dirty_insert_newhad no such split — it stored whatever was passed straight into ETS, so an%ConCache.Item{}ended up cached as the raw struct instead of its.value, and its.ttlwas silently ignored in favor of the cache's default ttl.Fix
Mirrors
dirty_put's two-clause pattern fordirty_insert_newvia a newperform_insert_new/4, soConCache.Itembehaves the same way for both functions.Testing
insert_newwith a%ConCache.Item{}unwraps to the plain value.mix test test/con_cache_test.exs: 54/60 passing both before and after this change — the 6 remaining failures are pre-existing on unmodifiedmastertoo (timing-sensitive ttl-expiry tests using ~10-40ms sleeps, flaky in this sandboxed environment; confirmed identical failure set onmaster).mix compile --warnings-as-errors: no new warnings from the changed file (the one pre-existing warning,unused require Loggerinlib/con_cache.ex, is unrelated and untouched by this change).🤖 Generated with Claude Code