@@ -98,13 +98,23 @@ func (c *Client) ExecuteAction(ctx context.Context, ac *Action) (*repb.ActionRes
9898}
9999
100100// CheckActionCache queries remote action cache, returning an ActionResult or nil if it doesn't exist.
101- func (c * Client ) CheckActionCache (ctx context.Context , acDg * repb.Digest ) (* repb.ActionResult , error ) {
101+ func (c * Client ) CheckActionCache (ctx context.Context , dg digest.Digest ) (* repb.ActionResult , error ) {
102+ if c .diskCache != nil {
103+ if res , loaded := c .diskCache .LoadActionCache (dg ); loaded {
104+ return res , nil
105+ }
106+ }
102107 res , err := c .GetActionResult (ctx , & repb.GetActionResultRequest {
103108 InstanceName : c .InstanceName ,
104- ActionDigest : acDg ,
109+ ActionDigest : dg . ToProto () ,
105110 })
106111 switch st , _ := status .FromError (err ); st .Code () {
107112 case codes .OK :
113+ if c .diskCache != nil {
114+ if err := c .diskCache .StoreActionCache (dg , res ); err != nil {
115+ log .Errorf ("error storing ActionResult of %s to disk cache: %v" , dg , err )
116+ }
117+ }
108118 return res , nil
109119 case codes .NotFound :
110120 return nil , nil
@@ -166,12 +176,13 @@ func (c *Client) PrepAction(ctx context.Context, ac *Action) (*repb.Digest, *rep
166176 if err != nil {
167177 return nil , nil , gerrors .WithMessage (err , "marshalling Action proto" )
168178 }
169- acDg := digest .NewFromBlob (acBlob ).ToProto ()
179+ dg := digest .NewFromBlob (acBlob )
180+ acDg := dg .ToProto ()
170181
171182 // If the result is cacheable, check if it's already in the cache.
172183 if ! ac .DoNotCache || ! ac .SkipCache {
173184 log .V (1 ).Info ("Checking cache" )
174- res , err := c .CheckActionCache (ctx , acDg )
185+ res , err := c .CheckActionCache (ctx , dg )
175186 if err != nil {
176187 return nil , nil , err
177188 }
0 commit comments