Check if protected and non-protected cache is shared

GitLab version: 15.7.8-ee

Either -protected or -non_protected or none suffix is automatically added to the cache key.

Is there a way check which suffix is used or if cache between protected and non-protected cache is shared in a job’s script:?

I looked through environment variables and did not find this information.

There is no built-in variable or option. I suppose you would need to check using GitLab API if the option is enabled on the project and determine it based on that.