10up / async-transients Goto Github PK
View Code? Open in Web Editor NEWARCHIVED: Transients that serve stale data while regenerating the new transients in the background.
License: MIT License
ARCHIVED: Transients that serve stale data while regenerating the new transients in the background.
License: MIT License
Currently, readme.md
says,
so make to you are loading your
vendor/autoload.php
file.
The word "to" appears to be a typo, perhaps "certain" instead.
"so make certain you are loading your vendor/autoload.php file."
Mind tagging an actual release of this?
It's not obvious the level of support provided for this repo, so let's add some clarification.
I've implemented this, but a new transient is not generated asynchronously, nor is the old transient returned when it has expired.
I've got a function that's supposed to return results, like so:
$transientKey = "pis".$_POST["language"].$_POST["month"].$_POST["year"];
$checkinNice = \TenUp\AsyncTransients\get_async_transient( $transientKey, 'get_month', array( $_POST["language"], $_POST["month"], $_POST["year"] ) );
if(!$checkinNice) {
$results = array();
}
else {
$results = $checkinNice;
}
Then, the 'get_month' function is like so:
function get_month($language, $month, $year) {
global $wpdb;
//Program items
$date_start = date('Y-m-d H:i:s', mktime(0,0,0,$_POST["month"] - 1,1,$_POST["year"]));
$date_end = date('Y-m-d H:i:s', -1 + mktime(0,0,0,$_POST["month"] + 2,1,$_POST["year"]));
$args = array(...);
$my_result = get_posts($args);
\TenUp\AsyncTransients\set_async_transient( "pis".$language.$month.$year, $my_result, DAY_IN_SECONDS );
}
This works, but when the transient has expired, the code takes as long to return results as without using async.
If my transient expires in 3 hours along with my page cache. How would I go about keeping the data fresh with Async ?
If the page cache is expired and the transient expires, its seems the data will always be 3 hours behind.
Is there a way I can add this process into a cache warming process and regenerate all of my soon to be expires transients than pre cache my pages with the new updated transients ?
This project is designed to update data "asynchronously", but the queue used does not persist across requests/threads, so if the callback is long-running enough, or the site has an even moderate amount of traffic, there's a good chance that the callback will be invoked more than once while the task is running.
This is a likely-enough scenario, that I feel like this functionality should be built in to the library. The cleanest path to this I can see is making the $queue
property be backed a (normal, WP Core) transient, and have callbacks added/removed from the queue as they are completed.
No response
No response
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.