Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cached delta updates #316

Merged
merged 2 commits into from
May 8, 2024
Merged

Cached delta updates #316

merged 2 commits into from
May 8, 2024

Conversation

alexsnaps
Copy link
Member

Waiting on #315 to be reviewed and merged

@adam-cattermole adam-cattermole mentioned this pull request May 7, 2024
Base automatically changed from cached_redis_tests to main May 7, 2024 15:55
@alexsnaps alexsnaps marked this pull request as ready for review May 7, 2024 15:56
@@ -292,43 +292,48 @@ impl CachedRedisStorageBuilder {
async fn update_counters<C: ConnectionLike>(
redis_conn: &mut C,
counters_and_deltas: HashMap<Counter, Arc<CachedCounterValue>>,
) -> Result<Vec<(Counter, i64, i64)>, StorageErr> {
) -> Result<Vec<(Counter, i64, i64, i64)>, StorageErr> {
Copy link
Contributor

Choose a reason for hiding this comment

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

the new value corresponds to the delta in the last position? maybe we could add an doc annotation to this fn

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll burn the whole ttl stuff, use absolute timestamps instead and then refactor this...
I hate tuples... of 4 elements even more so.

let (_, val, delta, ttl) = &mut res[i];
*val = script_res[j];
*delta = script_res[j] - *delta;
*ttl = script_res[j + 1];
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, so last one is ttl

"req.method == \"GET\"",
c.limit().conditions().iter().collect::<Vec<_>>()[0]
NEW_VALUE_FROM_REDIS - INITIAL_VALUE_FROM_REDIS - LOCAL_INCREMENTS,
remote_increments
Copy link
Contributor

Choose a reason for hiding this comment

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

explicit, so we can make assertions with the redis deltas 👍🏼

Copy link
Contributor

@didierofrivia didierofrivia left a comment

Choose a reason for hiding this comment

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

🍸

@alexsnaps alexsnaps merged commit 1a5a24d into main May 8, 2024
20 checks passed
@alexsnaps alexsnaps deleted the cached_delta_updates branch May 8, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants