@@ -5,11 +5,13 @@ import type { CacheKeys } from "./get-cache-keys.js";
55export type CacheOptions = {
66 skipOnHit : boolean ;
77 saveOnError : boolean ;
8+ silent : boolean ;
89} ;
910
1011export const DEFAULT_CACHE_OPTIONS = {
1112 skipOnHit : true ,
1213 saveOnError : false ,
14+ silent : false ,
1315} ;
1416
1517export interface CacheDelegate {
@@ -29,11 +31,13 @@ export async function withCache<T>(
2931 cache ?: CacheDelegate ,
3032) : Promise < T | undefined > {
3133 const cacheImpl = cache ?? realCache ;
32- const { skipOnHit, saveOnError } = options ;
34+ const { skipOnHit, saveOnError, silent } = options ;
3335
34- core . info ( `Cached paths:\n - ${ paths . join ( "\n - " ) } ` ) ;
35- core . info ( `Cache key: ${ keys . primaryKey } ` ) ;
36- core . info ( `Cache restore keys:\n - ${ keys . restoreKeys . join ( "\n - " ) } ` ) ;
36+ if ( ! silent ) {
37+ core . info ( `Cached paths:\n - ${ paths . join ( "\n - " ) } ` ) ;
38+ core . info ( `Cache key: ${ keys . primaryKey } ` ) ;
39+ core . info ( `Cache restore keys:\n - ${ keys . restoreKeys . join ( "\n - " ) } ` ) ;
40+ }
3741
3842 const restoredKey = await cacheImpl . restoreCache (
3943 paths ,
@@ -44,13 +48,17 @@ export async function withCache<T>(
4448 const primaryKeyHit = restoredKey == keys . primaryKey ;
4549
4650 if ( restoredKey ) {
47- core . info ( `Cache restored from key: ${ restoredKey } ` ) ;
51+ if ( ! silent ) {
52+ core . info ( `Cache restored from key: ${ restoredKey } ` ) ;
53+ }
4854 } else {
4955 core . warning ( "No cache found" ) ;
5056 }
5157
5258 if ( primaryKeyHit && skipOnHit && ! saveOnError ) {
53- core . info ( "Skipping due to primary key hit" ) ;
59+ if ( ! silent ) {
60+ core . info ( "Skipping due to primary key hit" ) ;
61+ }
5462 return ;
5563 }
5664
0 commit comments