How To Use Caching With Runners


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.



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.

   machine: true
   resource_class: your-namespace/your-resource
     - run: echo "sent to job 2" >> /tmp/cache.txt
     - save_cache:
           - /tmp/cache.txt
         key: runner-cache-v1            

   machine: true
   resource_class: your-namespace/your-resource
     - restore_cache:
           - runner-cache-v1
     - run: cat /tmp/cache.txt


Additional Resources:

Was this article helpful?
0 out of 2 found this helpful



Article is closed for comments.