All predicatesShow sourcerdf_cache.pl -- Cache RDF triples

The library library(semweb/rdf_cache) defines the caching strategy for triples sources. When using large RDF sources, caching triples greatly speedup loading RDF documents. The cache library implements two caching strategies that are controlled by rdf_set_cache_options/1.

Local caching This approach applies to files only. Triples are cached in a sub-directory of the directory holding the source. This directory is called .cache (_cache on Windows). If the cache option create_local_directory is true, a cache directory is created if posible.

Global caching This approach applies to all sources, except for unnamed streams. Triples are cached in directory defined by the cache option global_directory.

When loading an RDF file, the system scans the configured cache files unless cache(false) is specified as option to rdf_load/2 or caching is disabled. If caching is enabled but no cache exists, the system will try to create a cache file. First it will try to do this locally. On failure it will try to configured global cache.

Source rdf_set_cache_options(+Options)
Change the cache policy. Provided options are:
  • enabled(Boolean) If true, caching is enabled.
  • local_directory(Name). Plain name of local directory. Default .cache (_cache on Windows).
  • create_local_directory(Bool) If true, try to create local cache directories
  • global_directory(Dir) Writeable directory for storing cached parsed files.
  • create_global_directory(Bool) If true, try to create the global cache directory.
Source rdf_cache_file(+URL, +ReadWrite, -File) is semidet
File is the cache file for URL. If ReadWrite is read, it returns the name of an existing file. If write it returns where a new cache file can be overwritten or created.
Source local_cache_file(+FileURL, -File) is det[private]
Return the name of the cache file for FileURL. The name is the plain filename with the .trp extension. As the URL is a file URL, it is guaranteed to be a valid filename. Assumes the hosting OS can handle multiple exensions (.x.y) though. These days thats even true on Windows.
Source url_cache_file(+URL, +Dir, +Ext, +RW, -Path) is semidet[private]
Determine location of cache-file for the given URL in Dir. If Ext is provided, the returned Path is ensured to have the specified extension.
Arguments:
RW- If read, no directories are created and the call fails if URL is not in the cache.
Source url_to_file(+URL, -File)[private]
Convert a URL in something that fits in a file, i.e. avoiding / and :. We simply replace these by -. We could also use www_form_encode/2, but confusion when to replace as well as the fact that we loose the '.' (extension) makes this a less ideal choice. We could also consider base64 encoding of the name.
Source replace(+Code)//[private]
Replace a character code that cannot safely be put in a filename. Should we use %XX?