You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be really useful to be able to link data structures to root nodes of the DOM in some way that can cache the contents of the node depending on the data structure's content.
Say a URL /shop/apple/iphone12 performs a database lookup, then builds up an entity and then binds it to the DOM, it would be useful to intercept the whole data cycle, compare it to a cache key (in this case, the URL (maybe the database response on more dynamic websites)), then not bother having to do any binding at all, bypassing any expensive operations.
Just an idea for now. Let's see if I can introduce this concept into any real world projects any time soon.
The text was updated successfully, but these errors were encountered:
functiongo(DynamicPath$dynamicPath, DocumentBinder$binder, SlowDatabase$db):void {
// A cache with the name of the element tag name is a good start.$cache = newBinderCacheThing("shop-item-details");
$shopItemDetailsElement = $document->querySelector("shop-item-details");
// Load from the cache according to the key - in this case, the dynamic path's "item".// but if the cache is invalid (missing or stale), run the slow function.$data = $cache->load($dynamicPath->get("item"), function(string$itemName)use($db) {
return$db->getItemFromSlowDatabase($itemName);
});
// The bindData function can be used as normal, but the $data is always going to be typed// as a "cached" data. The bindData function can detect that this is not a typical KVP// and if the cached data is fresh, load the innerHTML from the cache, so no manipulation or// looping is at all necessary.$binder->bindData($data, $shopItemDetailsElement);
}
Note: it's not just the loading of the data that takes time. On huge, complex data structures, the building up of the DOM takes a non-zero amount of time. If all of this could be skipped, then slow spots could be significantly sped up.
It would be really useful to be able to link data structures to root nodes of the DOM in some way that can cache the contents of the node depending on the data structure's content.
Say a URL
/shop/apple/iphone12
performs a database lookup, then builds up an entity and then binds it to the DOM, it would be useful to intercept the whole data cycle, compare it to a cache key (in this case, the URL (maybe the database response on more dynamic websites)), then not bother having to do any binding at all, bypassing any expensive operations.Just an idea for now. Let's see if I can introduce this concept into any real world projects any time soon.
The text was updated successfully, but these errors were encountered: