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
#4 brought async support to most of the xk6-redis APIs. Currently, await is not currently supported, so there is no way to interact with Redis synchronously for most APIs.
// await is not supportedconstcounter=awaitredisClient.get('my_counter');if(counter>10){// do something in VU code}
I discussed this briefly with @mstoykov and @sniku. It seems that async APIs does not allow using using Redis for some particular cases.
The main reason is that Promise handlers are always executed after the VU code. Let's show one example:
exportdefaultfunction(){CONSOLE.log(`before async ${exec.vu.idInTest}`);redisClient.incr('my_key').then((total)=>{// this will only be executed when the VUs code finalizesCONSOLE.log(`promise callback ${exec.vu.idInTest}`);});sleep(Math.random()*5);CONSOLE.log(`exit VU code ${exec.vu.idInTest}`);}
In this case, the execution will always be in this order:
before async 1
exit VU code 1
promise callback 1
With async APIs, the result of a promise cannot change the VU execution code (outside the promise handler). Users could not do something like:
letlocalCounter=0;redisClient.get('my_counter').then((counter)=>{localCounter=counter;});while(localCounter===0){// VU will be blocked in this loop.}
This issue requests to provide "sync" support for Redis APIs to not limit the potential of using Redis in k6 tests. For example, to share data across VUs in your load test.
#4 brought async support to most of the xk6-redis APIs. Currently,
await
is not currently supported, so there is no way to interact with Redis synchronously for most APIs.I discussed this briefly with @mstoykov and @sniku. It seems that async APIs does not allow using using Redis for some particular cases.
The main reason is that Promise handlers are always executed after the VU code. Let's show one example:
In this case, the execution will always be in this order:
before async 1 exit VU code 1 promise callback 1
With async APIs, the result of a promise cannot change the VU execution code (outside the promise handler). Users could not do something like:
This issue requests to provide "sync" support for Redis APIs to not limit the potential of using Redis in k6 tests. For example, to share data across VUs in your load test.
cc @oleiade
The text was updated successfully, but these errors were encountered: