From b75a263c7615e73fbe5796f1a6af426bb21f2356 Mon Sep 17 00:00:00 2001 From: Fifciuu Date: Tue, 27 Apr 2021 15:23:37 +0200 Subject: [PATCH 1/5] updated lock --- yarn.lock | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/yarn.lock b/yarn.lock index 03486a56..d5657dc1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4415,9 +4415,9 @@ lru-cache@^5.0.0: dependencies: yallist "^3.0.2" -"mage2vuestorefront@git+https://github.com/DivanteLtd/mage2vuestorefront.git": - version "1.11.0" - resolved "git+https://github.com/DivanteLtd/mage2vuestorefront.git#6b477d35b6d11f935b1643938881969f16c87c04" +"mage2vuestorefront@git+https://github.com/vuestorefront/mage2vuestorefront.git": + version "1.11.1" + resolved "git+https://github.com/vuestorefront/mage2vuestorefront.git#a2abf48ec40d9fb761ee3f5117a1c87dc7f7c0c6" dependencies: "@elastic/elasticsearch" "^7.3.0" agentkeepalive "^3.3.0" @@ -4428,8 +4428,8 @@ lru-cache@^5.0.0: jsonfile "^4.0.0" jwt-simple "^0.5.1" kue "^0.11.5" - lodash "^4.17.13" - magento2-rest-client "0.0.2" + lodash "^4.17.19" + magento2-rest-client "https://github.com/DivanteLtd/magento2-rest-client" moment "^2.22.2" node-sync "^0.2.1" passport "^0.3.2" @@ -4449,19 +4449,19 @@ lru-cache@^5.0.0: request "^2.72.0" winston "^2.2.0" -magento2-rest-client@0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/magento2-rest-client/-/magento2-rest-client-0.0.2.tgz#2a6ef230c88129a8680b63ead3793ea7e99bf6a4" - integrity sha1-Km7yMMiBKahoC2Pq03k+p+mb9qQ= +"magento2-rest-client@github:vuestorefront/magento2-rest-client": + version "0.0.14" + uid "3ed81008e617abfed347ed42fb52ac9d72c8705b" + resolved "https://codeload.github.com/vuestorefront/magento2-rest-client/tar.gz/3ed81008e617abfed347ed42fb52ac9d72c8705b" dependencies: humps "^1.1.0" oauth-1.0a "^1.0.1" request "^2.72.0" winston "^2.2.0" -"magento2-rest-client@github:DivanteLtd/magento2-rest-client": - version "0.0.12" - resolved "https://codeload.github.com/DivanteLtd/magento2-rest-client/tar.gz/fb5adcb24fe25e097c2127a3ded5ef05e0fcb2f7" +"magento2-rest-client@https://github.com/DivanteLtd/magento2-rest-client": + version "0.0.14" + resolved "https://github.com/DivanteLtd/magento2-rest-client#3ed81008e617abfed347ed42fb52ac9d72c8705b" dependencies: humps "^1.1.0" oauth-1.0a "^1.0.1" @@ -6694,9 +6694,9 @@ stealthy-require@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b" -"storefront-query-builder@https://github.com/DivanteLtd/storefront-query-builder.git": - version "1.0.1" - resolved "https://github.com/DivanteLtd/storefront-query-builder.git#0ef1f9760eb44edce5b9464a9145ce0a7517a419" +"storefront-query-builder@https://github.com/vuestorefront/storefront-query-builder.git": + version "1.0.2" + resolved "https://github.com/vuestorefront/storefront-query-builder.git#7416993f07927f598d22ca448462f0d3f0288f20" dependencies: "@typescript-eslint/parser" "^2.26.0" clone-deep "^4.0.1" From 2bda974966d6922a78cb7e6e33015408a816ca27 Mon Sep 17 00:00:00 2001 From: Anders Ekelund Date: Thu, 28 Oct 2021 10:39:53 +0200 Subject: [PATCH 2/5] Add tags to be able to purge attributes from cache --- src/api/attribute/service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/api/attribute/service.ts b/src/api/attribute/service.ts index c437a1cd..a9e3e8dc 100644 --- a/src/api/attribute/service.ts +++ b/src/api/attribute/service.ts @@ -62,7 +62,8 @@ async function setAttributeInCache (attributeList, config) { await Promise.all( attributeList.map(attribute => (cache as TagCache).set( 'api:attribute-list' + attribute.attribute_code, - attribute + attribute, + ['attribute'] )) ) } catch (err) { From 086003e0caa27cce7d8ff18cebc16793ce1a22a0 Mon Sep 17 00:00:00 2001 From: Anders Ekelund Date: Thu, 28 Oct 2021 10:40:43 +0200 Subject: [PATCH 3/5] Add indexName to cache key to separate potentially translated attribute labels and values --- src/api/attribute/service.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/api/attribute/service.ts b/src/api/attribute/service.ts index a9e3e8dc..47ab2075 100644 --- a/src/api/attribute/service.ts +++ b/src/api/attribute/service.ts @@ -39,11 +39,11 @@ function transformAggsToAttributeListParam (aggregations): AttributeListParam { /** * Returns attributes from cache */ -async function getAttributeFromCache (attributeCode: string, config) { +async function getAttributeFromCache (attributeCode: string, config, indexName) { if (config.server.useOutputCache && cache) { try { const res = await (cache as TagCache).get( - 'api:attribute-list' + attributeCode + 'api:' + indexName + ':attribute-list:' + attributeCode ) return res } catch (err) { @@ -56,12 +56,12 @@ async function getAttributeFromCache (attributeCode: string, config) { /** * Save attributes in cache */ -async function setAttributeInCache (attributeList, config) { +async function setAttributeInCache (attributeList, config, indexName) { if (config.server.useOutputCache && cache) { try { await Promise.all( attributeList.map(attribute => (cache as TagCache).set( - 'api:attribute-list' + attribute.attribute_code, + 'api:' + indexName + ':attribute-list:' + attribute.attribute_code, attribute, ['attribute'] )) @@ -91,7 +91,7 @@ async function list (attributesParam: AttributeListParam, config, indexName: str // here we check if some of attribute are in cache const rawCachedAttributeList = await Promise.all( - attributeCodes.map(attributeCode => getAttributeFromCache(attributeCode, config)) + attributeCodes.map(attributeCode => getAttributeFromCache(attributeCode, config, indexName)) ) const cachedAttributeList = rawCachedAttributeList @@ -126,7 +126,7 @@ async function list (attributesParam: AttributeListParam, config, indexName: str const fetchedAttributeList = get(response.body, 'hits.hits', []).map(hit => hit._source) // save atrributes in cache - await setAttributeInCache(fetchedAttributeList, config) + await setAttributeInCache(fetchedAttributeList, config, indexName) // cached and fetched attributes const allAttributes = [ From e6b5259841ff3abc4b4860e7651451000da91d63 Mon Sep 17 00:00:00 2001 From: Anders Ekelund Date: Fri, 29 Oct 2021 16:52:55 +0200 Subject: [PATCH 4/5] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c872a84c..a58fed2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.12.5] - Unreleased + +### Fixed +- Fix caching of attributes. They were missing cache tag, preventing them from being purged correctly and also not separated cache key between multi stores (#583) + ## [1.12.4] - 2021.01.15 ### Fixed From 46df3077a5d0e5855052cdf4c65b03c352dc660c Mon Sep 17 00:00:00 2001 From: Fifciuu Date: Tue, 2 Nov 2021 10:18:48 +0100 Subject: [PATCH 5/5] chore: version bump to 1.12.5 --- CHANGELOG.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a58fed2e..fea1dce0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [1.12.5] - Unreleased +## [1.12.5] - 2021.11.02 ### Fixed - Fix caching of attributes. They were missing cache tag, preventing them from being purged correctly and also not separated cache key between multi stores (#583) diff --git a/package.json b/package.json index 230aa549..71faa8d0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-storefront-api", - "version": "1.12.4", + "version": "1.12.5", "private": true, "description": "vue-storefront API and data services", "main": "dist",