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

Support deferred expiration of records and attributes for one-to-many associations #577

Merged
merged 7 commits into from
Oct 10, 2024

Conversation

drinkbeer
Copy link
Contributor

@drinkbeer drinkbeer commented Oct 6, 2024

  • Deferred the expiration of child records and attributes to the end of transaction
  • Used batch operations (delete_multi/write_multi) instead of expire each record in a loop
  • In dev.yml, create the test database identity_cache_test in Mysql, achieved it by adding a Rake task

@drinkbeer drinkbeer requested review from kirs, Stivaros and a team October 6, 2024 21:49
@danmayer
Copy link

danmayer commented Oct 7, 2024

nice looking pretty good so far... Why did you need to add exists? that wasn't clear to me on first read

Copy link
Contributor

@Stivaros Stivaros left a comment

Choose a reason for hiding this comment

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

Really excited to see this feature coming along!

lib/identity_cache.rb Outdated Show resolved Hide resolved
test/test_helper.rb Outdated Show resolved Hide resolved
lib/identity_cache/query_api.rb Outdated Show resolved Hide resolved
lib/identity_cache/cache_fetcher.rb Show resolved Hide resolved
@drinkbeer drinkbeer marked this pull request as ready for review October 7, 2024 15:43
test/test_helper.rb Outdated Show resolved Hide resolved
lib/identity_cache.rb Outdated Show resolved Hide resolved
@drinkbeer drinkbeer force-pushed the jchen/deferred_expiration branch from 80d2148 to 7595790 Compare October 9, 2024 05:44
lib/identity_cache.rb Outdated Show resolved Hide resolved
@drinkbeer drinkbeer requested a review from Stivaros October 9, 2024 21:37
Comment on lines -50 to -53
if Thread.current[:idc_deferred_parent_expiration]
Thread.current[:idc_parent_records_for_cache_expiry] << parent
next parent
end
Copy link
Contributor Author

@drinkbeer drinkbeer Oct 9, 2024

Choose a reason for hiding this comment

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

The parent.expire_primary_index underlying calls the primary_index.expire, so we have an if block in the primary_index.expire, we don't need separate Set here. Just make the parent and associated records in one Set, and call write_multi to the keys. It will make the code simpler and easier to understand.

@drinkbeer drinkbeer merged commit 822af82 into main Oct 10, 2024
5 checks passed
@drinkbeer drinkbeer deleted the jchen/deferred_expiration branch October 10, 2024 16:03
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.

5 participants