Interface ModuleKey

  • All Superinterfaces:
    ReaderBase

    public interface ModuleKey
    extends ReaderBase
    SPI for identifying, resolving, caching, and resolving a Pkl module. Standard implementations can be created using ModuleKeys.
    • Method Detail

      • getUri

        java.net.URI getUri()
        Returns the absolute URI of this module. This URI is used for identifying the module in user facing messages, for example stack traces. Typically, this URI contains all information necessary for resolving and loading the module.
      • isCached

        default boolean isCached()
        Tells if this module should be cached in memory.

        Caching a module means caching its entire evaluation state, not just its resolved URI or source code.

        Turning off module caching is mostly useful for synthetic modules that cannot be referenced (imported) from other modules. An example for this is a module representing code typed in a REPL.

      • isLocal

        default boolean isLocal()
        Tells if the modules represented by this module key is local to the environment.

        A module that is local, and also ReaderBase.hasHierarchicalUris(), supports triple-dot imports.

        As a best practice, a module key should be considered local if its source can be loaded in a low latency environment (for example, from disk or from memory). On the flip-side, a module loaded from a remove server should not be considered local.

      • getFileCacheLocation

        default @Nullable java.nio.file.Path getFileCacheLocation()
        The relative file cache path for this module, or null if this module should not be cached on the file system.