From 8b4681470075d34d63dffd2e4648ccedbbd8fa97 Mon Sep 17 00:00:00 2001 From: Naz Date: Wed, 17 Aug 2022 19:03:04 +0200 Subject: [PATCH] Reworked image sizes cache to work with async cache refs https://github.com/TryGhost/Toolbox/issues/364 - The caches can be or async nature. Having await syntax allows to support both types - sync and async. --- .../core/server/lib/image/cached-image-size-from-url.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ghost/core/core/server/lib/image/cached-image-size-from-url.js b/ghost/core/core/server/lib/image/cached-image-size-from-url.js index 86a64341ad..83e634dabe 100644 --- a/ghost/core/core/server/lib/image/cached-image-size-from-url.js +++ b/ghost/core/core/server/lib/image/cached-image-size-from-url.js @@ -41,7 +41,7 @@ class CachedImageSizeFromUrl { return; } - const cachedImageSize = this.cache.get(url); + const cachedImageSize = await this.cache.get(url); if (cachedImageSize) { debug('Read image from cache:', url); @@ -50,7 +50,7 @@ class CachedImageSizeFromUrl { } else { try { const res = await this.getImageSizeFromUrl(url); - this.cache.set(url, res); + await this.cache.set(url, res); debug('Cached image:', url); @@ -64,7 +64,7 @@ class CachedImageSizeFromUrl { } // in case of error we just attach the url - this.cache.set(url, { + await this.cache.set(url, { url });