Function create_job must know what deployment to create a job in. It finds the correct deployment by getting the list (which requires a REST call) and looking for the one with the correct name. We can cache the results of this function to avoid the delay from the REST call.
A simple cache wouldn't work correctly if the deployment gets deleted during the lifetime of an instance of the library: it wouldn't realize that the deployment is gone, and would never update the cache. We therefore need to catch the corresponding errors, clear the cache, and try again.
Function
create_job
must know what deployment to create a job in. It finds the correct deployment by getting the list (which requires a REST call) and looking for the one with the correct name. We can cache the results of this function to avoid the delay from the REST call.A simple cache wouldn't work correctly if the deployment gets deleted during the lifetime of an instance of the library: it wouldn't realize that the deployment is gone, and would never update the cache. We therefore need to catch the corresponding errors, clear the cache, and try again.