You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the method current_object_is_synchronized is called 3 times in a row in the same page, we make 3 database calls.
The elements doesn't change between such page load, and until the elements is deleted from the database relations or changed, the data doesn't expire.
This problem is particulary proheminent on attachment listing pages, the methods can be called from 2 to 10 times for each image depending on the number of image sizes.
I think this is a great idea to add a cache layer on theses calls.
The best way to handle this is to use the wp_cache API (wp_cache_get/wp_cache_set) and use a group for theses.
The implementation need to
Handle get_object_id_for_receiver that generate a cache key like from_receiver:{types}{receiver_id}:{receiver_line_id}
Handle get_object_id_for_emitter that generates a cache key like from_emitter:{types}{emitter_id}:{emitter_line_id}
Handle current_object_is_synchronized that generates a cache key like from_receiver:{types}{receiver_id}:{receiver_line_id}
Have a global group into the object since the ressources can be called from anywhere into a multisite and doesn't change wp_cache_add_global_groups
Have a method that allows us to pass a row from the relation table, and clear all possibly generated keys from cache for the resource, with the whole line we can regenerate the keys generated from all the other methods
Theses are the mainly used methods into the code.
I think a method to generate the cache keys from the entries (from_emitter and from_receiver) will be usefull for this.
The text was updated successfully, but these errors were encountered:
By the way, we need to store that there is no relation into the cache with a false value and not forget to clear cache on relation creation after this.
Hello,
If the method
current_object_is_synchronized
is called 3 times in a row in the same page, we make 3 database calls.The elements doesn't change between such page load, and until the elements is deleted from the database relations or changed, the data doesn't expire.
This problem is particulary proheminent on attachment listing pages, the methods can be called from 2 to 10 times for each image depending on the number of image sizes.
I think this is a great idea to add a cache layer on theses calls.
The best way to handle this is to use the wp_cache API (wp_cache_get/wp_cache_set) and use a group for theses.
The implementation need to
get_object_id_for_receiver
that generate a cache key likefrom_receiver:{types}{receiver_id}:{receiver_line_id}
get_object_id_for_emitter
that generates a cache key likefrom_emitter:{types}{emitter_id}:{emitter_line_id}
current_object_is_synchronized
that generates a cache key likefrom_receiver:{types}{receiver_id}:{receiver_line_id}
wp_cache_add_global_groups
Theses are the mainly used methods into the code.
I think a method to generate the cache keys from the entries (from_emitter and from_receiver) will be usefull for this.
The text was updated successfully, but these errors were encountered: