File tree Expand file tree Collapse file tree 1 file changed +23
-23
lines changed
packages/utils/src/lib/server/cache Expand file tree Collapse file tree 1 file changed +23
-23
lines changed Original file line number Diff line number Diff line change @@ -45,34 +45,34 @@ export class S3Cache<V extends Uint8Array = Uint8Array> extends BaseCache<V> {
45
45
46
46
public async get ( key : string ) : Promise < V | undefined > {
47
47
const s3Key = this . buildKey ( key ) ;
48
- const head = await this . #client. send (
49
- new HeadObjectCommand ( {
50
- Bucket : this . #options. bucket ,
51
- Key : s3Key ,
52
- } ) ,
53
- ) ;
54
-
55
- if ( ! head . Metadata ) {
56
- return undefined ;
57
- }
48
+ try {
49
+ const head = await this . #client. send (
50
+ new HeadObjectCommand ( {
51
+ Bucket : this . #options. bucket ,
52
+ Key : s3Key ,
53
+ } ) ,
54
+ ) ;
58
55
59
- const expiresAtStr = head . Metadata ?. [ 'expires-at' ] ;
60
- if ( expiresAtStr && Date . now ( ) > Number . parseInt ( expiresAtStr , 10 ) ) {
61
- await this . delete ( key ) ;
62
- return undefined ;
63
- }
56
+ const expiresAtStr = head . Metadata ?. [ 'expires-at' ] ;
57
+ if ( expiresAtStr && Date . now ( ) > Number . parseInt ( expiresAtStr , 10 ) ) {
58
+ await this . delete ( key ) ;
59
+ return undefined ;
60
+ }
64
61
65
- const res = await this . #client. send (
66
- new GetObjectCommand ( {
67
- Bucket : this . #options. bucket ,
68
- Key : s3Key ,
69
- } ) ,
70
- ) ;
62
+ const res = await this . #client. send (
63
+ new GetObjectCommand ( {
64
+ Bucket : this . #options. bucket ,
65
+ Key : s3Key ,
66
+ } ) ,
67
+ ) ;
71
68
72
- if ( ! res . Body ) {
69
+ if ( ! res . Body ) {
70
+ return undefined ;
71
+ }
72
+ return res . Body . transformToByteArray ( ) as Promise < V > ;
73
+ } catch {
73
74
return undefined ;
74
75
}
75
- return res . Body . transformToByteArray ( ) as Promise < V > ;
76
76
}
77
77
78
78
public async set (
You can’t perform that action at this time.
0 commit comments