BucketCacheOptions Struct
Example
ts
declare const sourceBucket: s3.Bucket;
declare const myCachingBucket: s3.Bucket;
new codebuild.Project(this, 'ProjectA', {
source: codebuild.Source.s3({
bucket: sourceBucket,
path: 'path/to/source-a.zip',
}),
// configure the same bucket and path prefix
cache: codebuild.Cache.bucket(myCachingBucket, {
prefix: 'cache',
// use the same cache namespace
cacheNamespace: 'cache-namespace',
}),
buildSpec: codebuild.BuildSpec.fromObject({
version: '0.2',
phases: {
build: {
commands: ['...'],
},
},
// specify the same cache key and paths
cache: {
key: 'unique-key',
paths: [
'/root/cachedir/**/*',
],
},
}),
});
new codebuild.Project(this, 'ProjectB', {
source: codebuild.Source.s3({
bucket: sourceBucket,
path: 'path/to/source-b.zip',
}),
// configure the same bucket and path prefix
cache: codebuild.Cache.bucket(myCachingBucket, {
prefix: 'cache',
// use the same cache namespace
cacheNamespace: 'cache-namespace',
}),
buildSpec: codebuild.BuildSpec.fromObject({
version: '0.2',
phases: {
build: {
commands: ['...'],
},
},
// specify the same cache key and paths
cache: {
key: 'unique-key',
paths: [
'/root/cachedir/**/*',
],
},
}),
});
Properties
cacheNamespaceoptionalstringcache_namespaceoptionalstrcacheNamespaceoptionalStringCacheNamespaceoptionalstringCacheNamespaceoptional*string#Defines the scope of the cache.
Default: undefined - No cache namespace, which means that the cache is not shared across multiple projects.
You can use this namespace to share a cache across multiple projects.
The prefix to use to store the cache in the bucket.