Overview
Caching is a great way to optimize performance of job operations by reusing saved data from previous jobs. Setting up a cache within a self-hosted runner is the same process as if you were using CircleCI infrastructure.
Utilization
To utilize the caching feature on a runner, the data that needs to be cached should be placed in a common directory such as /tmp/.
When restoring the cache, the data will be restored in the same common folder.
job1:
machine: true
resource_class: your-namespace/your-resource
steps:
- run: echo "sent to job 2" >> /tmp/cache.txt
- save_cache:
paths:
- /tmp/cache.txt
key: runner-cache-v1
job2:
machine: true
resource_class: your-namespace/your-resource
steps:
- restore_cache:
keys:
- runner-cache-v1
- run: cat /tmp/cache.txt
Associated Costs
When making use of caches in a self-hosted runner, there will be additional costs incurred associated with network egress.
This means you will be charged for any data restored to the runner, but not data saved from the runner.
As such, there will be a cost associated with restore_cache, but not save_cache.
Comments
Article is closed for comments.