-
Notifications
You must be signed in to change notification settings - Fork 23
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
Cached delta updates #316
Conversation
78b1a2b
to
5a3a2a0
Compare
@@ -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> { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 👍🏼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍸
Waiting on #315 to be reviewed and merged