Skip to content

feat(cache): add backward compatibility for pako 1.x to 2.x migration#1383

Merged
JamieMagee merged 3 commits intoclearlydefined:masterfrom
elaine-mattos:fix/add-pako-compatibility
Jan 30, 2026
Merged

feat(cache): add backward compatibility for pako 1.x to 2.x migration#1383
JamieMagee merged 3 commits intoclearlydefined:masterfrom
elaine-mattos:fix/add-pako-compatibility

Conversation

@elaine-mattos
Copy link
Copy Markdown
Contributor

Hi,

as part of the Node.js and package updates effort (#1340), here is the follow-up PR that adds backward compatibility to handle Redis cache entries compressed with both pako 1.x (binary string) and pako 2.x (base64) formats, preventing cache invalidation during the upgrade.

Summary

Adds backward compatibility to handle Redis cache entries compressed with both pako 1.x (binary string) and pako 2.x (base64) formats, preventing cache invalidation during the upgrade.

Changes

  • Format detection in redis.js: Automatically detects whether cached data is in old binary string format (pako 1.x) or new base64 format (pako 2.x)
  • Backward compatibility: Existing cache entries remain readable after upgrading to pako 2.x
  • Test coverage: Added comprehensive tests for both def_* (definitions) and hrv_* (harvest) key patterns

Testing

  • Unit tests verify reading both old (pako 1.x binary) and new (pako 2.x base64) formats
  • Tested with local Redis container using keys written with pako 1.x and read with pako 2.x
  • Tests use both pako@1.0.8 and pako@2.1.0 to prove cross-version compatibility

Benefits

  • Zero cache invalidation on deployment
  • Seamless migration from pako 1.x to 2.x
  • Both formats coexist during transition period

service: config.get('CACHING_REDIS_SERVICE'),
apiKey: config.get('CACHING_REDIS_API_KEY'),
port: Number(config.get('CACHING_REDIS_PORT')) || 6380
port: Number(config.get('CACHING_REDIS_PORT'))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the removal of || 6380 here intentional? redis.js has it in the function signature default, and config.js has added the fallback.

Comment thread package.json Outdated
Comment on lines +127 to +128
"pako": "^2.1.0",
"pako-1": "npm:pako@^1.0.8"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: sort alphabetically.

Copy link
Copy Markdown
Collaborator

@qtomlinson qtomlinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the migration and the unit tests!

Comment thread package.json Outdated
Comment thread providers/caching/redis.js
@JamieMagee JamieMagee force-pushed the fix/add-pako-compatibility branch from c72ba89 to 19da150 Compare January 30, 2026 18:13
Signed-off-by: ElaineDeMattosSilvaB <elaine.de-mattos-silva-bezerra@deutschebahn.com>
Signed-off-by: ElaineDeMattosSilvaB <elaine.de-mattos-silva-bezerra@deutschebahn.com>
Signed-off-by: ElaineDeMattosSilvaB <elaine.de-mattos-silva-bezerra@deutschebahn.com>
@JamieMagee JamieMagee force-pushed the fix/add-pako-compatibility branch from 19da150 to b7e2c03 Compare January 30, 2026 23:10
@JamieMagee JamieMagee merged commit 62e875b into clearlydefined:master Jan 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants