• Resolved Mehrshad Darzi

    (@mehrshaddarzi)


    Hi
    Thank you for publishing this plugin.

    I want to use this plugin for a big project that has Redis Cache Plugin.
    Why you not use wp_set_cache function in insert_cache_row Method in Your code.
    Is there a specific reason?

    At present, with each request, the information is read from the MySQL database table but can be read from the cache, such as Radis.

Viewing 1 replies (of 1 total)
  • Plugin Author Richard Korthuis

    (@rockfire)

    Hi @mehrshaddarzi

    Thank you for your question. Yes there is a specific reason, but before I explain the reason let me first tell you that we do use wp_set_cache (or to be more specific set_transient) to store the actual cached data.

    Now for the reason why we also use these MySQL tables:
    Whenever a post (or taxonomy) is edited / deleted / created we want to flush all caches that have this post in it. Now if we would only store all data about the caches inside the transients, we can only request (and flush) those transients by their specific transient name. Now since we didn’t store any information about these caches outside the transient we have no way of knowing which caches to flush.

    How about if we make the transient name something like post_12 (for the /wp-json/wp/v2/posts/12 call)? That might work, but limits you to the “main” post inside the response (what if in that same result you can also have the featured image and that featured image has been edited?). Our plugin tries to determine all relations within the result (therefore the wrc_relations table). It is a limitation, but it could be a decision to use this limitation. But how about the posts endpoint ( /wp-json/wp/v2/posts )? How would we store that in such a way we know how and when to flush it? Using posts as transient name? But that doesn’t tell us which posts are in this call, and what about the arguments you can use to retrieve this endpoint? A call to /wp-json/wp/v2/posts?search=test will result in a completely different response, so it should be a different cache record.

    As you can see, depending solely on the transient API would limit our options extremely, we wouldn’t be able to automatically flush (the correct) caches whenever a post is edited. Therefore we need those MySQL tables. Or do you see any other option?

    Now for the reason behind your question: you are worried about the performance because of those SQL queries? I can tell you the impact of those queries is minimal and the alternative (not using our plugin) isn’t great for performance either ??

Viewing 1 replies (of 1 total)
  • The topic ‘Compatible wrc_caches and wrc_relations MySQL table with WordPress Cache API’ is closed to new replies.