Skip to content

Conversation

@dfinkel
Copy link

@dfinkel dfinkel commented Dec 3, 2025

Directly support jittering the TTL/expiry to make it easy to do the
right thing. (bound the expiration as necessary)

Copy link

@sergiosalvatore sergiosalvatore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor nit...

galaxycache.go Outdated
}

// WithGetTTL allows the client to specify a default TTL for the galaxy, with optional jitter
// jitter may be 0 to always set the TTL to exactly ttl in the future after calling the BackendGetter.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence seems to be worded strangely... (Same on L547)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following our in-person discussion, I've rewritten the semantics to only jitter to earlier-times, and rewritten/expanded these doc-comments. (and updated the package-level doc and a mention in the top-level README -- that needs a more general update that I'll try to get to after the current project is done)

I also moved WithPeekTTL into the PeekPeerCfg struct.

Copy link

@sergiosalvatore sergiosalvatore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple little nits.

galaxycache.go Outdated
//
// Expiration times of values with an expiration earlier than maxTTL in the
// future are left alone no matter the source. (e.g. the value may have
// originally had a TTL in the same range, but have been sitting in the cache

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I'm following here...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done a little rewording. Hopefully that helps?

galaxycache.go Outdated
Comment on lines 459 to 461
// When used, Jitter values should be large enough that over a reasonable
// number of maxTTL intervals, keys that are continually accessed will be
// spread their expiration across the entire interval.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// When used, Jitter values should be large enough that over a reasonable
// number of maxTTL intervals, keys that are continually accessed will be
// spread their expiration across the entire interval.
// When used, Jitter values should be large enough that, over a reasonable
// number of maxTTL intervals, keys that are continually accessed will
// spread their expiration across the entire interval.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fixes.
applied.

galaxycache.go Outdated
// Negative TTLs and jitter values are silently ignored, and jitter values that
// are greater than maxTTL will be capped at maxTTL.
PeekedValueMaxTTL time.Duration `dialsdesc:"max time in the future to allow a value pulled in via a Peek request have their expiration"`
PeekedValueTTLJitter time.Duration `dialsdesc:"max time to reduce the "`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: truncated dialsdesc

galaxycache.go Outdated
Comment on lines 598 to 600
// When used, Jitter values should be large enough that over a reasonable
// number of maxTTL intervals, keys that are continually accessed will be
// spread their expiration across the entire interval.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// When used, Jitter values should be large enough that over a reasonable
// number of maxTTL intervals, keys that are continually accessed will be
// spread their expiration across the entire interval.
// When used, Jitter values should be large enough that, over a reasonable
// number of maxTTL intervals, keys that are continually accessed will
// spread their expiration across the entire interval.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Directly support jittering the TTL/expiry to make it easy to do the
right thing. (bound the expiration as necessary)
@dfinkel dfinkel merged commit 872fc1d into master Dec 8, 2025
8 checks passed
@dfinkel dfinkel deleted the galaxy_ttl_config branch December 8, 2025 21:18
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.

3 participants