digitalbazaar / jsonld.js

A JSON-LD Processor and API implementation in JavaScript
https://json-ld.org/
Other
1.64k stars 195 forks source link

Use a per-`documentLoader` resolved context cache. #552

Open davidlehn opened 1 month ago

davidlehn commented 1 month ago

Fixes an issue where multiple document loaders are used which each have different values for static contexts.

A WeakMap is used for caches and is cleaned up using WeakMap semantics based on the lifetime of the documentLoader keys.

davidlehn commented 1 month ago

A bit more info for this issue:

About this initial fix:

For future work, the entire caching setup should be revisited. Apps should have more control over cache use, size, and duration. There are many ways this could be designed.