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

feat: delta cache manager #760

Merged
merged 5 commits into from
Feb 21, 2025
Merged

feat: delta cache manager #760

merged 5 commits into from
Feb 21, 2025

Conversation

kwasniew
Copy link
Contributor

@kwasniew kwasniew commented Feb 20, 2025

About the changes

We used store delta cache per environment:
let delta_cache: DashMap<String, DeltaCache> = DashMap::default();
After this change we will be able to use:
let delta_cache_manager = DeltaCacheManager::new();
The manager will hide the dash map but also handle updates broadcasting for streaming purposes.

This API is symmetrical to how we handle FeatureCache. As a result switching streaming code from full updates to deltas will be almost a drop-in replacement.

Important files

Discussion points

Calling something a manager is controversial. I'm open to changing this name it but after this code is merged and used in another PR that I've been working on.

Copy link

github-actions bot commented Feb 20, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

Copy link
Member

@sighphyre sighphyre left a comment

Choose a reason for hiding this comment

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

Yeah the Rust looks good


#[derive(Debug, Clone)]
pub enum DeltaCacheUpdate {
Full(String), // environment with a newly inserted cache
Copy link
Member

Choose a reason for hiding this comment

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

Might be asking for too much here, but it's not possible for the Full to just be a special case of Update? Be cool to only have two cases here but I really dunno if that's possible with your future plans

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am considering dropping it altogether after I confirm it's not needed in the next PR

self.caches.get(env).map(|entry| entry.value().clone())
}

pub fn insert_cache(&self, env: String, cache: DeltaCache) {
Copy link
Member

Choose a reason for hiding this comment

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

Can I suggest taking a &str here? It usually makes for a nicer API when working with literals and since you're cloning it anyway in the body, there's no real hit to memory

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely

Copy link
Member

@chriswk chriswk left a comment

Choose a reason for hiding this comment

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

Except for Simon's comment on taking a &str instead of a String when inserting the cache, this LGTM

@kwasniew kwasniew merged commit d4f6dc5 into main Feb 21, 2025
17 checks passed
@kwasniew kwasniew deleted the delta-cache-manager-added branch February 21, 2025 08:40
This was referenced Feb 21, 2025
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.

3 participants