-
Notifications
You must be signed in to change notification settings - Fork 210
Add inline object caching to HPPS repositories #7904
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
Changes from 22 commits
ecb33fd
c27bf77
2e32f0a
4e2524c
43c447b
360fc91
3aad620
5fc5d01
9827d82
eedf0ba
bea908b
b3887c7
e8a934d
e656c4c
22a8f33
86fb93a
e3e9440
f48cec8
c892aca
323cf60
c7f4517
30dee5b
d6311ab
d9a3889
c0e8871
20fec9e
448db59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Significance: minor | ||
| Type: added | ||
|
|
||
| Add object caching to HPPS (High-Performance Progress Storage) repositories |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,13 @@ class Progress_Storage_Settings { | |
| */ | ||
| public const TABLES_STORAGE = 'custom_tables'; | ||
|
|
||
| /** | ||
| * Memoized cache-enabled flag. Null means not yet computed. | ||
| * | ||
| * @var bool|null | ||
| */ | ||
| private static ?bool $cache_enabled = null; | ||
|
|
||
| /** | ||
| * Get the storage repositories. | ||
| * | ||
|
|
@@ -89,4 +96,41 @@ public static function is_tables_repository(): bool { | |
| public static function is_sync_enabled(): bool { | ||
| return Sensei()->settings->settings['experimental_progress_storage_synchronization'] ?? false; | ||
| } | ||
|
|
||
| /** | ||
| * Returns true if HPPS caching is enabled. | ||
| * | ||
| * Defaults to true when using tables-based storage. Filterable via `sensei_hpps_cache_enabled`. | ||
| * | ||
| * @since $$next-version$$ | ||
| * | ||
| * @return bool | ||
| */ | ||
| public static function is_cache_enabled(): bool { | ||
| if ( null === self::$cache_enabled ) { | ||
| /** | ||
| * Filter whether HPPS caching is enabled. | ||
| * | ||
| * @hook sensei_hpps_cache_enabled | ||
| * | ||
| * @since $$next-version$$ | ||
| * | ||
| * @param {bool} $enabled Whether caching is enabled. | ||
| * @return {bool} Whether caching should be enabled. | ||
| */ | ||
| self::$cache_enabled = (bool) apply_filters( 'sensei_hpps_cache_enabled', self::is_tables_repository() ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No action needed, but the WP Cache API is a little annoying here. I could see a site wanting a persistent cache (like Memcached) for most of their site but to only use a in-memory (not persisted) cache for Sensei. That's possible, but it requires different tweaking depending on what WP Cache dropin the site has installed, so it isn't anything we can do in the plugin.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could reconsider this in the future if we get reports about people wanting to do this. |
||
| } | ||
| return self::$cache_enabled; | ||
| } | ||
|
|
||
| /** | ||
| * Reset the memoized cache-enabled flag. Useful for tests. | ||
| * | ||
| * @since $$next-version$$ | ||
| * | ||
| * @internal | ||
| */ | ||
| public static function reset_cache_enabled(): void { | ||
| self::$cache_enabled = null; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.