Utilites for caching file contents
Functions:
-
read_file_and_cache
–Read and cache string contents of files for quick access and reducing IO operations.
-
read_url_and_cache
–Read and cache text responses from URL
read_file_and_cache
read_file_and_cache(filepath)
Read and cache string contents of files for quick access and reducing IO operations.
Note
May need "forgetting" mechanism if too many large files are stored. Should be fine for loading JSON metamodels and SHACL constraints in Turtle format.
Source code in src/rdf_utils/caching.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
read_url_and_cache
read_url_and_cache(url, timeout=_GLOBAL_DEFAULT_TIMEOUT)
Read and cache text responses from URL
Parameters:
-
url
(str
) –URL to be opened with urllib
-
timeout
(float
, default:_GLOBAL_DEFAULT_TIMEOUT
) –duration in seconds to wait for response. Only works for HTTP, HTTPS & FTP. Default:
socket._GLOBAL_DEFAULT_TIMEOUT
will be used, which usually means no timeout.
Source code in src/rdf_utils/caching.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|