When two pipelines are executed simultaneously, do they access the cache concurrently?

When all pipelines use the same cache key to reference a cache, if two pipelines are executed simultaneously, will they concurrently use the same cached file? Alternatively, if one pipeline is using it, will the other pipeline wait until it becomes available?

For example,

  - compile

  stage: compile
    key: cache-key
      - /.gradle
    - echo "complie stage" 

If you have configured the yml as described above, when pipeline A starts and removes /.gradle for cache refresh, is there a potential issue where pipeline B, starting in this situation, might not be able to find /.gradle ?

GitLab Runner will restore and extract the cache in a CI/CD job.

When the job finishes, the cache gets saved again.

Example from build-latest (#5664790900) · Jobs · Developer Evangelism and Technical Marketing at GitLab / use-cases / CICD Components Catalog / Components (Templates) / Component - Rust Basic · GitLab

If jobs run concurrently, they might download the same cache, but later override the cache upload, depending which job finishes first. To prevent that, you can use resource_groups to lock the job, not being run in parallel. Resource group | GitLab

Alternatively, configure a cache key that is not global, but per branch. Caching in GitLab CI/CD | GitLab