How To Use Caching With Runners

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

 

Additional Resources:

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

Comments

0 comments

Article is closed for comments.