class Cache
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.CodeBuild.Cache |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awscodebuild#Cache |
Java | software.amazon.awscdk.services.codebuild.Cache |
Python | aws_cdk.aws_codebuild.Cache |
TypeScript (source) | aws-cdk-lib » aws_codebuild » Cache |
Cache options for CodeBuild Project.
A cache can store reusable pieces of your build environment and use them across multiple builds.
See also: https://docs.aws.amazon.com/codebuild/latest/userguide/build-caching.html
Example
declare const myCachingBucket: s3.Bucket;
new codebuild.Project(this, 'Project', {
source: codebuild.Source.bitBucket({
owner: 'awslabs',
repo: 'aws-cdk',
}),
cache: codebuild.Cache.bucket(myCachingBucket),
// BuildSpec with a 'cache' section necessary for S3 caching. This can
// also come from 'buildspec.yml' in your source.
buildSpec: codebuild.BuildSpec.fromObject({
version: '0.2',
phases: {
build: {
commands: ['...'],
},
},
cache: {
paths: [
// The '**/*' is required to indicate all files in this directory
'/root/cachedir/**/*',
],
},
}),
});
Initializer
new Cache()
Methods
Name | Description |
---|---|
static bucket(bucket, options?) | Create an S3 caching strategy. |
static local(...modes) | Create a local caching strategy. |
static none() |
static bucket(bucket, options?)
public static bucket(bucket: IBucket, options?: BucketCacheOptions): Cache
Parameters
- bucket
IBucket
— the S3 bucket to use for caching. - options
Bucket
— additional options to pass to the S3 caching.Cache Options
Returns
Create an S3 caching strategy.
static local(...modes)
public static local(...modes: LocalCacheMode[]): Cache
Parameters
- modes
Local
— the mode(s) to enable for local caching.Cache Mode
Returns
Create a local caching strategy.
static none()
public static none(): Cache
Returns