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

Main plugin features #11

Merged
merged 35 commits into from
Dec 3, 2022
Merged

Main plugin features #11

merged 35 commits into from
Dec 3, 2022

Conversation

srtfisher
Copy link
Member

@srtfisher srtfisher commented Nov 9, 2022

Adds a cache collector that stores key/group pairs that can be purged altogether.

One use case is storing all the places where a post is used. When that post is updated, the cache collector can purge all the caches the post is used in instead of having to add a manual call to clean_post_cache.

Update 11/16

This was refactored after feedback from @mboynes to not be driven by options but rather store the cache collection's keys on the post/term itself. When a cache collection is registered for a term/post it will store the collection as meta on the post itself which can then be used for purging.

@srtfisher srtfisher enabled auto-merge November 10, 2022 00:10
Copy link
Member

@dlh01 dlh01 left a comment

Choose a reason for hiding this comment

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

I left some notes and questions throughout. Hopefully they're not too badly misinformed. I'm happy to look over any updates, or feel free to drop the PR back in the queue to get a final read from someone a little closer to the work.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
plugin.php Outdated Show resolved Hide resolved
plugin.php Outdated Show resolved Hide resolved
plugin.php Outdated Show resolved Hide resolved
src/class-cache-collector.php Show resolved Hide resolved
src/class-cache-collector.php Show resolved Hide resolved
src/class-cache-collector.php Show resolved Hide resolved
src/class-cache-collector.php Outdated Show resolved Hide resolved
Comment on lines +519 to +520
WP_Post::class => update_post_meta( $this->parent->ID, static::META_KEY, $keys ),
WP_Term::class => update_term_meta( $this->parent->term_id, static::META_KEY, $keys ),
Copy link
Member

Choose a reason for hiding this comment

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

The use of a single array of keys is still, I think, subject to the race condition that you and Boynes discussed in Slack. However, using the metadata API allows for a possible workaround: for each key, store a separate meta row. That way, concurrent requests would write to their own rows, not the same row? I haven't played that all the way out in my head, so maybe it's a dead end.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oooo, i like this

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've thought this through and I think I grasp the idea here but I don't know (right now) how to implement it. I split out ticket #14 to investigate it further.

@srtfisher srtfisher disabled auto-merge December 3, 2022 00:27
@srtfisher
Copy link
Member Author

@dlh01 thank you very much for taking a deep dive here. your feedback really helped push this to be a better plugin than it was. I really like the improvements made here

@srtfisher srtfisher merged commit 01ada9d into main Dec 3, 2022
@srtfisher srtfisher deleted the feature branch December 3, 2022 00:39
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.

2 participants