Skip to content

Bundle the transcoder's properties into EVCacheTranscoderProperties#198

Closed
joegoogle123 wants to merge 1 commit into
evcache-value-binary-serdefrom
evcache-value-binary-serde-transcoder-properties
Closed

Bundle the transcoder's properties into EVCacheTranscoderProperties#198
joegoogle123 wants to merge 1 commit into
evcache-value-binary-serdefrom
evcache-value-binary-serde-transcoder-properties

Conversation

@joegoogle123

@joegoogle123 joegoogle123 commented Jun 30, 2026

Copy link
Copy Markdown

Summary

Route the EVCacheValue binary-serialization toggle through a new EVCacheTranscoderProperties bundle instead of an inline propertyRepository.get(...).get() chain in EVCacheImpl. The bundle is a typed extension point — every property it exposes resolves through the same three-level chain, and new transcoder properties land on the Key enum without touching call sites.

What changed

  • New EVCacheTranscoderProperties (com.netflix.evcache.config): holds the bundle. Key enum carries both the per-app suffix and the global key per property. Constructor (String appName, PropertyRepository propertyRepository) snapshots every property at construction. Today's only entry is USE_BINARY_SERIALIZATION — additional transcoder properties drop in here.
  • EVCacheTranscoder now has a (int max, int compressionThreshold, EVCacheTranscoderProperties properties) ctor that stores the bundle and consults properties.isBinarySerializationEnabled() inside serialize(). The previous (int, int, boolean) ctor is removed; the (int, int) ctor builds a bundle with appName=null so no-app callers fall through to the global key.
  • EVCacheImpl drops the inline <app>.envelope.binary.serialization.enabled read and the ENVELOPE_COMPRESSION_DISABLED constant, building the bundle once per app.

Three-level resolution

Per property, resolved at construction:

  1. <appName>.<appSuffix> — per-app override
  2. <globalKey> — fleet-wide global
  3. compiled-in static default

For USE_BINARY_SERIALIZATION: appSuffix binary.serialization.enabled, globalKey default.evcache.binary.serialization.enabled, default false.

Property-key rename ⚠️

This PR renames the FastProperty introduced in #196:

Before (#196) After (this PR)
Per-app <app>.envelope.binary.serialization.enabled <app>.binary.serialization.enabled
Global evcache.envelope.binary.serialization.enabled default.evcache.binary.serialization.enabled

Rationale: align the global key with the default.evcache.… convention used by the other transcoder properties, and drop the envelope. prefix that was implicit-already (the transcoder is the envelope codec). Any caller who set the old keys will need to migrate.

Dynamic-property escape hatch

Future fields that need runtime mutability can skip the cached primitive and call EVCacheTranscoderProperties#getProperty(Key, Class, defaultValue) per access — the same three-level chain applies. PR #197's setCompressionAlgorithmProperty / setCompressionLevelProperty setters on EVCacheSerializingTranscoder are orthogonal and untouched here.

Stacked on

Base is evcache-value-binary-serde (PR #196). When #196 merges, this PR's base auto-updates to master.

Test plan

  • ./gradlew :evcache-core:test — green. Five new tests in EVCacheTranscoderPropertiesTest:
    • per-app override wins
    • global fallback when per-app unset
    • static default when both unset
    • per-app beats global when both set
    • null appName routes through the global key (for the no-app ctor path)
  • Re-run joelee-sample-app smoke test against a republished snapshot. The smoke test's @TestPropertySource will need updating to the renamed property keys.

🤖 Generated with Claude Code

@joegoogle123 joegoogle123 force-pushed the evcache-value-binary-serde-transcoder-properties branch from 77d50a3 to d02b7a1 Compare June 30, 2026 21:27
@joegoogle123 joegoogle123 changed the title Bundle the transcoder's three FastProperties into EVCacheTranscoderProperties Bundle the transcoder's properties into EVCacheTranscoderProperties Jun 30, 2026
…nscoderProperties

Today EVCacheImpl reads the binary-serialization FastProperty inline:

```java
final boolean useBinarySerialization = propertyRepository.get(_appName + ".envelope.binary.serialization.enabled", Boolean.class)
        .orElseGet("evcache.envelope.binary.serialization.enabled").orElse(false).get();
this.evcacheValueTranscoder = new EVCacheTranscoder(maxValueSize, ENVELOPE_COMPRESSION_DISABLED, useBinarySerialization);
```

This change introduces an EVCacheTranscoderProperties bundle that owns the
read and exposes the result behind a typed accessor. Each property follows a
uniform three-level resolution chain:

  1. <appName>.<appSuffix>   (per-app override)
  2. <globalKey>             (fleet-wide global)
  3. compiled-in static default

Today the bundle holds exactly one property — USE_BINARY_SERIALIZATION,
appSuffix `binary.serialization.enabled`, globalKey
`default.evcache.binary.serialization.enabled`. The Key enum is the
extension point: new transcoder properties land here and inherit the same
chain without touching the call sites.

EVCacheTranscoder gains a (int, int, EVCacheTranscoderProperties) ctor that
stores the bundle and consults `properties.isBinarySerializationEnabled()`
inside `serialize()`. The old (int, int, boolean) ctor is gone; the 2-arg
(int, int) ctor constructs a properties object with appName=null so the
no-app callers naturally fall through to the global key.

EVCacheImpl drops the inline read and the ENVELOPE_COMPRESSION_DISABLED
constant, building the bundle once per app.

NOTE on property key naming: the global key changed from
`evcache.envelope.binary.serialization.enabled` to
`default.evcache.binary.serialization.enabled`, matching the
`default.evcache.…` convention used by the other transcoder properties.
The per-app suffix is `binary.serialization.enabled` (no `envelope.`
prefix). Any caller who set the old global key will need to migrate.

Future fields that need runtime-dynamic reads can call the bundle's
`getProperty(Key, Class, default)` method instead of caching at
construction. PR #197's setCompressionAlgorithmProperty /
setCompressionLevelProperty setters on EVCacheSerializingTranscoder are
orthogonal and untouched here.

Tests: 5 new tests in EVCacheTranscoderPropertiesTest cover per-app
override, global fallback, static default, per-app-beats-global precedence,
and null-appName routing to the global key.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joegoogle123 joegoogle123 force-pushed the evcache-value-binary-serde-transcoder-properties branch from d02b7a1 to 7130343 Compare June 30, 2026 21:35
@joegoogle123

Copy link
Copy Markdown
Author

Folding the transcoder-properties commit into PR #196; we'll squash at merge.

@joegoogle123 joegoogle123 deleted the evcache-value-binary-serde-transcoder-properties branch June 30, 2026 23:11
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.

1 participant