Is cache action effective without restore-keys?

Currently we are using a workflow template which includes an actions/cache key but no restore-keys value specified. We do not seem to get many (if any) cache hits on our projects.
I am wondering:

  • Would adding a restore-keys value e.g. venv-${{ runner.os }}-${{ matrix.python-version }}- increase our cache hit rate?

  • Would this incur any risk of ‘poisoning’ the cache by fetching an unexpected value which does not correspond to the correct build?

Yes in most cases, the cache key is going to be used by the action to grab the latest cache based on that key, which would automatically infer a cache hit. This should work for your use case.