• Resolved nicmare

    (@nicmare)


    I am using a transient to count API-Requests on a foreign database. If i reach a count of 5000 requests, i stop requesting the database. No with SQLite the counter of the transient is always 0 and i am worried i could exceed the allowed number of api-requests now because there is no limit any more. I wonder if i can exclude my custom transient from caching or how to handle this scenario without transients?!

    • This topic was modified 11 months, 3 weeks ago by nicmare.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author OllieJones

    (@olliejones)

    Thanks for your question. Are you telling me that this SQLite Object Cache is returning an incorrect value for a transient? If so, that’s a serious defect in the plugin and I really need to track it down.

    Could you please share with me the source code where you set and update this transient?

    That being said, there’s no way to avoid caching just one transient. You can avoid caching any transient, and instead storing them in the MariaDB / MySQL database by mentioning ‘transient’ in a call to wp_cache_add_non_persistent_groups()

    wp_cache_add_non_persistent_groups('transient');

    Thread Starter nicmare

    (@nicmare)

    Thats the code for reading the transient which stays zero when SQLite is running:

    i can give you a temporary admin access to the staging site if you are really interested. please send me a PN or a mail and i will answer with credentials.

    Plugin Author OllieJones

    (@olliejones)

    It would help to see the calls your code makes to set_transient() as well as get_transient().

    I would indeed like to take a look at your staging site, thanks for offering. My Github profile says how to get in touch, and it is mentioned in my WordPress.org profile here. https://profiles.wordpress.org/olliejones/

    Thread Starter nicmare

    (@nicmare)

    email sent – thank you very much in advance!

    Thread Starter nicmare

    (@nicmare)

    Thanks for this information, Nic.

    A quick thought. When the persistent object cache is active, transients are stored in it and not in the main database. Take a look at the source code here.

    https://github.com/WordPress/wordpress-develop/blob/6.7/src/wp-includes/option.php#L1532-L1601

    So, they vanish when you activate the plugin. And, when you deactivate the plugin whatever transients were in the main database come back.

    Do you expect your transient to persist when you activate or deactivate the persistent object cache plugin?

    I suppose I could add code to copy transients from the main database to the object cache on activation, and back on deactivation.  But I am almost certain the other persistent object cache plugins don’t do this.  What happens if you simply leave the plugin activated?

    Ollie Jones

    i think i need to rewrite my code with that incremental counter based on transients. maybe a write a counter logic in a file. somehow the caching of transients makes me nervous in this specific case. thank you

    Plugin Author OllieJones

    (@olliejones)

    Please don’t hesitate to open another support thread if you have further problems. I think this one is resolved.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Can i exclude specific transients from being cached?’ is closed to new replies.