• Resolved sx1001

    (@sx1001)


    Hi all,

    I want to activate the Database Cache in W3TC, even for logged in users, on our Buddypress Membershpi page. Therefore I need so technically understand a few things. I’d love to only “whitelist” specific queries which I know run over and over again and always return the same result. My current problem is: I can’t maintain all my caching patches across the different plugins, hence I’m looking to therefore feed the DB results into an persistent cache at the “last place” before it goes to the Database.

    Is something like that possible using W3TC (whitelisting the desired queries to be cached)?

    And is my understanding correct, that the functionality would work this way (quite similar to the object cache which already uses wp_cache_set/get): Instead of querying the database, the wpdb dropin class would make use of wp_cache_set/get, which in turn would basically use the persistent object cache (like memcached/redis)?

    In case it’d be possible to first record all running queries (with a run-counter) and afterwards to define my own query whitelist, this would be awesome. Because it would enable be to feed the database results to the object cache for a defined period of time and enable me to use this across all queries (no matter where they are originally coming from).

    Thanks so much!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @sx1001

    Thank you for reaching out and I am happy to help!
    With Object Caching you are caching application objects and with DB Caching you are aching raw query results.

    What you are sugegsting cannot be done with any plugin. In W3 Total Cache you can exclude specific query stems, query words or disable DB Caching if some specific constat is defined for some template.
    Without some custom implementation, this is not possible in the W3 Total Cache.

    Thanks!

    Thread Starter sx1001

    (@sx1001)

    OK, thanks for the answer.

    Still I’m a bit confused by your statement “What you are sugegsting cannot be done with any plugin.”. Yes, indeed, maybe raw query results cannot easily be cached – but what could be done is implement a custom wpdb extension and at least add caching to get_var(), get_col(), get_row() and get_results and, for a given set of parameters, cache the return values of these functions if they the queries match a given whitelist entry/pattern.

    This way, those functionalities would still use the wpdb->query() function indeed, yes, but only once every X seconds/minutes. Effectively this would allow for storing/caching the final return-values of those wpdb functions (which are mainly objects or arrays when uing ARRAY_A parameter) in a memcached/redis cache and return them the next time the same SQL query is ran on the same wpdb function.

    Don’t you think this would be a major major improvement? It would allow developers to cache so many stuff which runs over and over again during all pageloads.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @sx1001

    I’ll share your request with the team so we can discuss this.

    Currently this is not available in the W3TC DB caching option

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.