Does anyone know if there is a WordPress function to get the timeout value of a saved transient? I am using a transient with a 5 minute timeout to cache data from a web API call locally. Between transient timeouts I load the data locally from the transient acting as a cache and secondary API throttle. What I would like to do is read and display the timeout value of the currently saved transient data so the user knows how long they need to wait before the next data refresh. The value is stored in the ‘wp_options’ table as ‘_transient_timeout_transient-name’, so I assume I could use the global $wpdb object and just do a SQL query, but I wanted to make sure there wasn’t a more elegant way.
Leave a Reply
You must be logged in to post a comment.
So, after one minute of more thinking, there is an easy solution, although i did not try it myself:
you should be ready to go with this.
Another Way throught the database would be:
the returned value is a timestamp, but i’m sure you know how to handle it from here.