java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.codebuild.Cache
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.112.0 (build de1bc80)", date="2025-07-29T17:50:57.185Z") @Stability(Stable) public abstract class Cache extends software.amazon.jsii.JsiiObject
Cache options for CodeBuild Project.

A cache can store reusable pieces of your build environment and use them across multiple builds.

Example:

 Vpc vpc;
 SecurityGroup mySecurityGroup;
 CodeBuildStep.Builder.create("Synth")
         // ...standard ShellStep props...
         .commands(List.of())
         .env(Map.of())
         // If you are using a CodeBuildStep explicitly, set the 'cdk.out' directory
         // to be the synth step's output.
         .primaryOutputDirectory("cdk.out")
         // Control the name of the project
         .projectName("MyProject")
         // Control parts of the BuildSpec other than the regular 'build' and 'install' commands
         .partialBuildSpec(BuildSpec.fromObject(Map.of(
                 "version", "0.2")))
         // Control the build environment
         .buildEnvironment(BuildEnvironment.builder()
                 .computeType(ComputeType.LARGE)
                 .privileged(true)
                 .build())
         .timeout(Duration.minutes(90))
         .fileSystemLocations(List.of(FileSystemLocation.efs(EfsFileSystemLocationProps.builder()
                 .identifier("myidentifier2")
                 .location("myclodation.mydnsroot.com:/loc")
                 .mountPoint("/media")
                 .mountOptions("opts")
                 .build())))
         // Control Elastic Network Interface creation
         .vpc(vpc)
         .subnetSelection(SubnetSelection.builder().subnetType(SubnetType.PRIVATE_WITH_EGRESS).build())
         .securityGroups(List.of(mySecurityGroup))
         // Control caching
         .cache(Cache.bucket(new Bucket(this, "Cache")))
         // Additional policy statements for the execution role
         .rolePolicyStatements(List.of(
             PolicyStatement.Builder.create().build()))
         .build();
 

See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject

    software.amazon.jsii.JsiiObject.InitializationMode
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
    protected
    Cache(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    Cache(software.amazon.jsii.JsiiObjectRef objRef)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Cache
    bucket(IBucket bucket)
    Create an S3 caching strategy.
    static Cache
    bucket(IBucket bucket, BucketCacheOptions options)
    Create an S3 caching strategy.
    static Cache
    Create a local caching strategy.
    static Cache
     

    Methods inherited from class software.amazon.jsii.JsiiObject

    jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface software.amazon.jsii.JsiiSerializable

    $jsii$toJson
  • Constructor Details

    • Cache

      protected Cache(software.amazon.jsii.JsiiObjectRef objRef)
    • Cache

      protected Cache(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • Cache

      @Stability(Stable) protected Cache()
  • Method Details

    • bucket

      @Stability(Stable) @NotNull public static Cache bucket(@NotNull IBucket bucket, @Nullable BucketCacheOptions options)
      Create an S3 caching strategy.

      Parameters:
      bucket - the S3 bucket to use for caching. This parameter is required.
      options - additional options to pass to the S3 caching.
    • bucket

      @Stability(Stable) @NotNull public static Cache bucket(@NotNull IBucket bucket)
      Create an S3 caching strategy.

      Parameters:
      bucket - the S3 bucket to use for caching. This parameter is required.
    • local

      @Stability(Stable) @NotNull public static Cache local(@NotNull LocalCacheMode... modes)
      Create a local caching strategy.

      Parameters:
      modes - the mode(s) to enable for local caching. This parameter is required.
    • none

      @Stability(Stable) @NotNull public static Cache none()