param name="url.pollID" type="string"; // Lists in Redis provide both blocking and non-blocking operations. In this case, // we're going to use BLPOP (Blocking Left-Pop) to block-and-hang the parent page // request for several seconds (3) while waiting for the given list to be populated. // If no list-item can be popped in the given timeout, the result will be null. results = application.redisGateway.withRedis( ( redis ) => { var blockTimeout = 3; // Time to block in seconds. var lists = [ "poll:#url.pollID#" ]; var popResult = redis.blpop( blockTimeout, lists ); // The result of the BLPOP operation is 2-tuple where the first index is the // name of the key (since we can block on multiple keys at the same time); // and, the second index is the value of the list item that we popped. if ( ! isNull( popResult ) ) { return( popResult[ 2 ] ); } } ); // If there was no result, the job is still processing. For the sake of simplicity, // let's just return a 404 Not Found in this case. if ( isNull( results ) ) { header statuscode = 404 statustext = "Not Found" ; exit; } content type = "application/x-json" variable = charsetDecode( serializeJson( results ), "utf-8" ) ;