coldbox-modules / cbwire

CBWIRE is a ColdBox module that makes building reactive, modern apps easy using HTML-over-the-wire technologies and CFML.
https://cbwire.ortusbooks.com
Other
28 stars 5 forks source link

Automatically cache computed properties in the cache proxy for better performance #98

Closed grantcopley closed 1 year ago

grantcopley commented 1 year ago

Currently computed properties like this are invoked and re-ran every time they are used in a component's template.

#args.computed.orderStatuses()#
component extends="cbwire.models.Component" {

    computed = {
        "orderStatuses": function() {
            return ormExecuteQuery( "
            from OrderStatus
            where deleted = 0
            order by title
            ", {}, false ).map( function ( orderStatus ) {
                return "Status-" & orderStatus.getTitle();
            } );    
        },
    }
}

Automatically cache these after the first run.

Also, add the ability to bypass any caching by passing

#args.computed.orderStatuses( cache=false )#