From da40ad8fbe14c4e49c7c48eacd01b350578342e8 Mon Sep 17 00:00:00 2001 From: Daniel Zanzini Date: Tue, 6 Jun 2023 16:44:00 -0300 Subject: [PATCH 1/2] Adds hitRate to DiskCache --- CHANGELOG.md | 9 ++++++++- src/caches/DiskCache.ts | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bf4b8f9b..4e625b93c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Changed + +- Adds hitRate metric to DiskCache. + ## [6.45.15] - 2023-02-01 + ### Changed + - Removed unnecessary worker signal logs ## [6.45.14] - 2023-02-01 @@ -23,7 +29,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Do not return empty content if no conflict is found. ## [6.45.13] - 2022-12-12 + ### Changed + - Deterministic cache for getWithBody - Remove socket metrics per origin @@ -1756,7 +1764,6 @@ instead - `HttpClient` now adds `'Accept-Encoding': 'gzip'` header by default. - [Unreleased]: https://github.com/vtex/node-vtex-api/compare/v6.45.15...HEAD [6.45.15]: https://github.com/vtex/node-vtex-api/compare/v6.45.14...v6.45.15 [6.45.14]: https://github.com/vtex/node-vtex-api/compare/v6.45.13...v6.45.14 diff --git a/src/caches/DiskCache.ts b/src/caches/DiskCache.ts index af883c823..1232969ab 100644 --- a/src/caches/DiskCache.ts +++ b/src/caches/DiskCache.ts @@ -23,6 +23,7 @@ export class DiskCache implements CacheLayer{ public getStats = (name='disk-cache'): DiskStats => { const stats = { hits: this.hits, + hitRate: this.total > 0 ? this.hits / this.total : undefined, name, total: this.total, } From 0a1a21ad7ddaa40973bc9918732011e7a607fd53 Mon Sep 17 00:00:00 2001 From: Daniel Zanzini Date: Tue, 6 Jun 2023 16:46:07 -0300 Subject: [PATCH 2/2] Sorts key alhpabetically --- src/caches/DiskCache.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/caches/DiskCache.ts b/src/caches/DiskCache.ts index 1232969ab..2be901ea1 100644 --- a/src/caches/DiskCache.ts +++ b/src/caches/DiskCache.ts @@ -22,8 +22,8 @@ export class DiskCache implements CacheLayer{ public getStats = (name='disk-cache'): DiskStats => { const stats = { - hits: this.hits, hitRate: this.total > 0 ? this.hits / this.total : undefined, + hits: this.hits, name, total: this.total, }