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

Add initial functionality #1

Merged
merged 9 commits into from
Oct 18, 2024
Merged

Add initial functionality #1

merged 9 commits into from
Oct 18, 2024

Conversation

dlh01
Copy link
Member

@dlh01 dlh01 commented Oct 16, 2024

No description provided.

src/class-big-pit.php Outdated Show resolved Hide resolved
Copy link

@scottnelle scottnelle left a comment

Choose a reason for hiding this comment

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

Couple questions, no blockers. If you'd like to use a more descriptive name for this plugin, don't feel beholden to the name we joked about during retro. But if you want to stick with Big Pit, OK by me! 👻

/**
* Create or update the database table.
*/
private function upsert(): void {

Choose a reason for hiding this comment

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

Any value in returning bool here, true if it was already ready or if the db delta completed, false if not? You could check that result before declaring the featured ready.

* @param mixed $value Item value.
* @param string $group Item group.
*/
public function set( string $key, mixed $value, string $group ): void {

Choose a reason for hiding this comment

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

Might it be beneficial to return bool on the set and delete methods, to mirror the corresponding object cache methods?

Copy link
Contributor

Choose a reason for hiding this comment

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

this got me thinking that maybe this should do more than mirror the object cache! expanded on that in another comment

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 recently become somewhat skeptical of these return values. In addition to the possibility of ambiguity (does false mean the value wasn't deleted or that there was nothing to delete? would you return true even if no deletions took place?), have you found a use for them?

@mboynes
Copy link
Contributor

mboynes commented Oct 17, 2024

Wild idea: what if this were fully compatible with the WordPress object cache's (faux) interface? Then it could be an option for a database-driven object cache.

If it also used DI to take in an instance of WPDB instead of using the global $wpdb, it could theoretically use a separate database/instance to distribute load (this would make it more attractive as a db object cache, but I think the value is there regardless).

@dlh01
Copy link
Member Author

dlh01 commented Oct 18, 2024

Wild idea: what if this were fully compatible with the WordPress object cache's (faux) interface? Then it could be an option for a database-driven object cache.

If it also used DI to take in an instance of WPDB instead of using the global $wpdb, it could theoretically use a separate database/instance to distribute load (this would make it more attractive as a db object cache, but I think the value is there regardless).

Although I see the harmony, my initial reaction is that I'm not greatly attracted to this idea, for a couple reasons.

Compatibility with the object cache "interface" requires a decent amount of additional code, some of which might be used even when The Pit wasn't being used as the object cache (TTLs), but perhaps more of which would be dead when it wasn't being used as the object cache (hit rates, compatibility with wp_suspend_cache_addition()).

Additionally, I think it would compel the table itself to be a global table for multisite compatibility, and keys would need to be made site-specific. Again, that's complexity that runs up against (what I had in mind as) the intended scope of the library and the table.

If there's interest in a database-driven object cache, might I humbly suggest looking at the Training Object Cache that I worked on a few years ago as a starting point, where a lot of that legwork has been done.

See also the next PR, which opens a possibility for using The Pit as a cache store.

dlh01 and others added 2 commits October 17, 2024 23:51
Co-authored-by: Matthew Boynes <[email protected]>
@dlh01
Copy link
Member Author

dlh01 commented Oct 18, 2024

My plan is to merge this and tag an initial release as there's a project waiting to use it. I'll keep it at major version 0 so that this discussion can continue in issues (including about the name!) and we can refine the API before tagging a 1.0 release.

@dlh01 dlh01 merged commit 6774767 into main Oct 18, 2024
2 checks passed
@dlh01 dlh01 deleted the feature/0.1 branch October 18, 2024 19:44
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.

3 participants