I'm playing around with Coldbox futures and was ho...
# box-products
I'm playing around with Coldbox futures and was hoping to use it to execute a dozed or so database lookup table queries in parallel. We use a custom DAL that internally makes a reference to a scoped variable in the 'request' context called 'site'. Here is a bit of example code:
Copy code
            () => LookupRepository.getCategories()
            (results) => WriteLog(file='AsyncFutures',text="#serializeJSON(results)#")
            (results) => WriteLog(file='AsyncFutureErrors',text="#serializeJSON(results)#")
I'm getting an error in the 'AsyncFutureErrors' log about the key 'site' not existing in 'request' scope. Is the current request scope not visible inside of a cbfuture? It'd make sense. Is there a workaround? I'm absolutely new to CB Futures. Thanks.
You're right that it follows that a request scope wouldn't be available to an async future. You'd need to pull whatever you wanted out of the request scope and pass it into the async() closure
whatever is in
should be passed into the DAL to maintain encapsulation
Thanks. Unfortunately it's not possible to pass it into the DAL due to our app requirements. We'll be looking to cache this information in the near future so it's not a biggy.
@bdeline2 place the items to process in a array and process then with map or each with parallel set to true
Thanks. I will check that out.