CJM-115545: useServerInfoCache - Enables caching of server info and i…#127
CJM-115545: useServerInfoCache - Enables caching of server info and i…#127blfakir wants to merge 1 commit intoadobe:masterfrom
Conversation
package.json
Outdated
| { | ||
| "name": "@adobe/acc-js-sdk", | ||
| "version": "1.1.61", | ||
| "version": "1.1.62", |
There was a problem hiding this comment.
Could you keep this to 1.1.61? I'll do the release with a separate PR
src/client.js
Outdated
| * @property {number} timeout - Can be set to change the HTTP call timeout. Value is passed in ms. | ||
| * @property {string} cacheRootKey - "default" or "none" - determine the prefix to use for the keys in the caches of schemas, options, etc. | ||
| * @property {string} instanceKey - an optional value to override the instance key which is used for the caches of schemas, options, etc. | ||
| * @property {boolean} useServerInfoCache - Enables caching of server info and installed packages. Defaults to false |
There was a problem hiding this comment.
Can you add useServerInfoCache for consistency?
src/client.js
Outdated
| this._options.entityCacheTTL = options.entityCacheTTL || 1000*300; // 5 mins | ||
| this._options.methodCacheTTL = options.methodCacheTTL || 1000*300; // 5 mins | ||
| this._options.optionCacheTTL = options.optionCacheTTL || 1000*300; // 5 mins | ||
| this._options.useServerInfoCacheTTL = options.useServerInfoCacheTTL || 1000*60*60*24; // 1 day |
There was a problem hiding this comment.
Can you init useServerInfoCache for consistency?
src/client.js
Outdated
| const name = DomUtil.getAttributeAsString(pack, "name"); | ||
| const fullName = `${namespace}:${name}`; | ||
| this._installedPackages[fullName] = fullName; | ||
| packagesArray.push({ namespace, name }); |
| const useCache = this._useServerInfoCache && cachedPackages && cachedUserInfo && cachedLastPostUpgrade && cachedServerInfo; | ||
|
|
||
| if ( useCache) { | ||
| const sessionInfo = DomUtil.newDocument("sessionInfo"); |
There was a problem hiding this comment.
Is there any reason not to cache the whole XML document?
| if ( useCache) { | ||
| const sessionInfo = DomUtil.newDocument("sessionInfo"); | ||
| const sessionInfoRoot = sessionInfo.documentElement; | ||
| const serverInfoElement = sessionInfo.createElement('serverInfo'); |
There was a problem hiding this comment.
Could you add try/catch around the this block of code and log a warning +
fallbakc to not using the cache if there's an execption?
That way if cache get corrupted, the SDK willl gracefully fall back to not using the cache
| const crypto = require("crypto"); | ||
|
|
||
| const makeKey = () => { | ||
| const a = []; |
There was a problem hiding this comment.
No need to change identation (several occurrences)
7e09e5f to
1143380
Compare
docs/connectionParameters.html
Outdated
| </tbody> | ||
| </table> | ||
|
|
||
| pa No newline at end of file |
There was a problem hiding this comment.
why "pa" ?
there is new line missing
src/client.js
Outdated
| exports.ConnectionParameters = ConnectionParameters; | ||
| })(); | ||
src/client.js
Outdated
| * @property {number} entityCacheTTL - The TTL (in milliseconds) after which cached XTK entities expire. Defaults to 5 minutes | ||
| * @property {number} methodCacheTTL - The TTL (in milliseconds) after which cached XTK methods expire. Defaults to 5 minutes | ||
| * @property {number} optionCacheTTL - The TTL (in milliseconds) after which cached XTK options expire. Defaults to 5 minutes | ||
| * @property {number} useServerInfoCacheTTL - The TTL (in milliseconds) for the server info cache. Defaults to 1 day |
There was a problem hiding this comment.
should be serverInfoCacheTTL instead of useServerInfoCacheTTL right?
…nstalled packages. Defaults to false
1143380 to
ccbebc2
Compare
|
@obriard Done thx |
Description
Implements server info caching in client connection options.
useServerInfoCacheto enable caching of server info and installed packages.useServerInfoCacheTTLto control TTL of the cache (default 1 day).Related Issue
Motivation and Context
Reduces initial round-trips to fetch server info and installed packages, improving performance on repeated initializations.
How Has This Been Tested?
useServerInfoCacheand observing fewer transport calls after first fetch.Screenshots (if appropriate):
N/A
Types of changes
Checklist: