Skip to content

Commit 5157b5f

Browse files
Integrate a simple JSON-LD context cache
Signed-off-by: George J Padayatti <[email protected]>
1 parent 1127de6 commit 5157b5f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

mydata_did/v1_0/utils/jsonld/create_verify_data.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010

1111
from pyld import jsonld
1212

13+
cache = {}
14+
def caching_document_loader(url, options):
15+
loader = jsonld.requests_document_loader()
16+
if url in cache:
17+
return cache[url]
18+
resp = loader(url)
19+
cache[url] = resp
20+
return resp
21+
22+
jsonld.set_document_loader(caching_document_loader)
23+
1324

1425
def _canonize(data):
1526
return jsonld.normalize(

0 commit comments

Comments
 (0)