Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Feat/201 jitter #221

Merged
merged 4 commits into from
Jul 28, 2021
Merged

Feat/201 jitter #221

merged 4 commits into from
Jul 28, 2021

Conversation

jrconlin
Copy link
Member

Description

Adds a setting to add "jitter" to a given tiles in memory cache TTL

Testing

Set the CONTILE_JITTER=0 and note that tiles do not display jitter and expire exactly at CONTILE_TTL.
Set the CONTILE_JITTER=50 and note that tiles expire at any time between 50 and 150% of CONTILE_TTL.

Issue(s)

Closes #201

@jrconlin jrconlin requested review from pjenvey and a team July 23, 2021 22:46
let mut rng = thread_rng();
let ftl = settings.tiles_ttl as f32;
let offset = ftl * (std::cmp::min(settings.jitter, 50) as f32 * 0.01);
let jit = rng.gen_range(0.0 - offset..offset);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it be inclusive (I don't actually care 😄 )?

Suggested change
let jit = rng.gen_range(0.0 - offset..offset);
let jit = rng.gen_range(0.0 - offset..=offset);

@jrconlin jrconlin merged commit 2a35f96 into main Jul 28, 2021
@jrconlin jrconlin deleted the feat/201-jitter branch July 28, 2021 16:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add TTL jitter
2 participants