From 74be5d6b5159bed33b67e377a7fbf6383d66fee1 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Wed, 10 May 2023 09:04:33 +0200 Subject: [PATCH] implemented feedback of @akirk --- includes/collection/class-followers.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/includes/collection/class-followers.php b/includes/collection/class-followers.php index a6a8ba4..5e5e532 100644 --- a/includes/collection/class-followers.php +++ b/includes/collection/class-followers.php @@ -19,7 +19,7 @@ use function Activitypub\get_remote_metadata_by_actor; */ class Followers { const TAXONOMY = 'activitypub-followers'; - const CACHE_KEY_INBOXES = 'activitypub_follower_inboxes_for_%s'; + const CACHE_KEY_INBOXES = 'follower_inboxes_%s'; /** * Register WordPress hooks/actions and register Taxonomy @@ -226,8 +226,7 @@ class Followers { if ( is_wp_error( $result ) ) { return $result; } else { - $cache_key = sprintf( self::CACHE_KEY_INBOXES, $user_id ); - wp_cache_delete( $cache_key ); + wp_cache_delete( sprintf( self::CACHE_KEY_INBOXES, $user_id ), 'activitypub' ); return $follower; } } @@ -241,8 +240,7 @@ class Followers { * @return bool|WP_Error True on success, false or WP_Error on failure. */ public static function remove_follower( $user_id, $actor ) { - $cache_key = sprintf( self::CACHE_KEY_INBOXES, $user_id ); - wp_cache_delete( $cache_key ); + wp_cache_delete( sprintf( self::CACHE_KEY_INBOXES, $user_id ), 'activitypub' ); return wp_remove_object_terms( $user_id, $actor, self::TAXONOMY ); } @@ -375,7 +373,7 @@ class Followers { */ public static function get_inboxes( $user_id ) { $cache_key = sprintf( self::CACHE_KEY_INBOXES, $user_id ); - $inboxes = wp_cache_get( $cache_key ); + $inboxes = wp_cache_get( $cache_key, 'activitypub' ); if ( $inboxes ) { return $inboxes; @@ -415,7 +413,7 @@ class Followers { ); $inboxes = array_filter( $results ); - wp_cache_set( $cache_key, $inboxes ); + wp_cache_set( $cache_key, $inboxes, 'activitypub' ); return $inboxes; }