Skip to content

fix Redis bool cache key prefix#646

Merged
pk910 merged 1 commit into
ethpandaops:masterfrom
Sahil-4555:simplify-cache-and-handler-internals
Jun 2, 2026
Merged

fix Redis bool cache key prefix#646
pk910 merged 1 commit into
ethpandaops:masterfrom
Sahil-4555:simplify-cache-and-handler-internals

Conversation

@Sahil-4555

@Sahil-4555 Sahil-4555 commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes RedisCache.GetBool to use the configured Redis key prefix when reading values.

SetBool writes bool values using the prefixed key, but GetBool previously looked up the raw unprefixed key. This meant bool values stored through SetBool would not be found when a Redis prefix was configured.

Changes

  • Updated GetBool to read from the same prefixed key format used by SetBool.

Comment thread cache/redis_cache.go Outdated
@pk910

pk910 commented Jun 1, 2026

Copy link
Copy Markdown
Member

Heya @Sahil-4555

Thanks, I went through all the changes. They're technically clean.

Most of this is micro-optimization though (sprintf -> string concat, Replace -> TrimPrefix, %x -> hex.EncodeToString, bytes.Equal, ...) and I don't think it's worth merging just for that. The wins are in the ns range, but these all run inside page handlers that take milliseconds for processing and db queries anyway, so it won't make any measurable difference.

Two things did stand out as actual fixes rather than perf:

  • GetBool was missing the key prefix, so it would never match what SetBool writes. There's no caller for it in the app right now so it has no real impact today, but it's still a valid fix.
  • The re-check in isSszCompatible after taking the write lock is fine too. Just a note: it's not really a race, the map is already behind the mutex - it just avoids running ValidateType twice when two goroutines hit the write lock at the same time.

Could you pull the GetBool fix out into its own small PR? I'd happily merge that. The rest I'd rather leave out to keep the churn down.

@Sahil-4555 Sahil-4555 force-pushed the simplify-cache-and-handler-internals branch from 54b4ec0 to 482c753 Compare June 2, 2026 03:22
@Sahil-4555 Sahil-4555 changed the title perf: cache key building and handler hex processing fix Redis bool cache key prefix Jun 2, 2026
@Sahil-4555

Copy link
Copy Markdown
Contributor Author

Heya @Sahil-4555

Thanks, I went through all the changes. They're technically clean.

Most of this is micro-optimization though (sprintf -> string concat, Replace -> TrimPrefix, %x -> hex.EncodeToString, bytes.Equal, ...) and I don't think it's worth merging just for that. The wins are in the ns range, but these all run inside page handlers that take milliseconds for processing and db queries anyway, so it won't make any measurable difference.

Two things did stand out as actual fixes rather than perf:

  • GetBool was missing the key prefix, so it would never match what SetBool writes. There's no caller for it in the app right now so it has no real impact today, but it's still a valid fix.
  • The re-check in isSszCompatible after taking the write lock is fine too. Just a note: it's not really a race, the map is already behind the mutex - it just avoids running ValidateType twice when two goroutines hit the write lock at the same time.

Could you pull the GetBool fix out into its own small PR? I'd happily merge that. The rest I'd rather leave out to keep the churn down.

Done. let me know if there are any other feedback points.

@Sahil-4555 Sahil-4555 requested a review from pk910 June 2, 2026 03:26
@pk910 pk910 enabled auto-merge June 2, 2026 12:52
@pk910 pk910 merged commit 87d6530 into ethpandaops:master Jun 2, 2026
5 checks passed
@Sahil-4555 Sahil-4555 deleted the simplify-cache-and-handler-internals branch June 2, 2026 12:59
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.

2 participants