Skip to content

Fix client-level string_fastpath: true being silently ignored#1101

Merged
petergoldstein merged 2 commits into
mainfrom
fix/client-level-string-fastpath
May 18, 2026
Merged

Fix client-level string_fastpath: true being silently ignored#1101
petergoldstein merged 2 commits into
mainfrom
fix/client-level-string-fastpath

Conversation

@petergoldstein

Copy link
Copy Markdown
Owner

Fixes #1100.

Problem

Dalli::Client.new(servers, string_fastpath: true) had no effect. use_string_fastpath? only checked req_options, so the fast path was never taken for normal client.set(key, value) calls — only when string_fastpath: true was passed as a per-request option on each individual set.

The existing integration test at line 17 of test_serializer.rb didn't catch this because it only verified the round-trip result. Marshal also preserves string encoding, so the test passed whether or not the fast path was actually taken.

Fix

Add string_fastpath to ValueSerializer::DEFAULTS and OPTIONS so it is stored in @serialization_options at init time. In use_string_fastpath?, fall back to the client-level value when the per-request option is absent. Per-request still takes full precedence in both directions:

  • Per-request true overrides client-level false
  • Per-request false overrides client-level true

Tests

  • Existing integration test strengthened with a serializer spy to prove the fast path is actually taken (not just that the round-trip produces the right value).
  • New integration test covers per-request override in both directions.
  • New unit tests cover all four combinations of client-level and per-request option values directly against ValueSerializer#store.

Test plan

  • bundle exec ruby -Itest test/integration/test_serializer.rb — 6 runs, 40 assertions, 0 failures
  • bundle exec ruby -Itest test/protocol/test_value_serializer.rb — 32 runs, 68 assertions, 0 failures
  • bundle exec rubocop — no offenses

🤖 Generated with Claude Code

petergoldstein and others added 2 commits May 17, 2026 21:15
Closes #1100

`use_string_fastpath?` only checked `req_options`, so
`Dalli::Client.new(servers, string_fastpath: true)` had no effect on
normal `set` calls — the fast path was never taken unless the option was
also passed per-request.

Add `string_fastpath` to `ValueSerializer::DEFAULTS`/`OPTIONS` so it is
stored in `@serialization_options` at init time, and fall back to that
value in `use_string_fastpath?` when the per-request option is absent.
Per-request still takes full precedence (true overrides client-level
false, and false overrides client-level true).

Tighten the existing integration test with a serializer spy so it
actually verifies the fast path is taken rather than just that the
round-trip produces the right value (Marshal also preserves encoding, so
the old test passed even when the fast path was silently skipped).

Add an integration test for the per-request override behavior and unit
tests covering all four combinations of client-level and per-request
option values.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@petergoldstein petergoldstein merged commit 91e3756 into main May 18, 2026
18 checks passed
@petergoldstein petergoldstein deleted the fix/client-level-string-fastpath branch May 18, 2026 01:29
@petergoldstein petergoldstein mentioned this pull request May 18, 2026
2 tasks
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.

Client-level string_fastpath: true is silently ignored

1 participant