/workspace/cache
The module exports the cacheWorkspace method which returns a workspace from the module scope cache variable or call the cacheWorkspace method to cache the workspace.
Default templates can be overwritten in the workspace or by providing a CUSTOM_TEMPLATES environment variable which references a JSON with templates to be merged into the workspace.
- Source
Requires
Methods
(inner) cacheWorkspace() → {workspace}
The workspace is retrived from the source defined in the WORKSPACE environment variable.
Templates defined in the CUSTOM_TEMPLATES environment variable are spread into the default workspace.templates{}.
Each locale from the workspace.locale{} is merged into the workspace.locale{} template.
Locale objects get their key and name properties assigned if falsy.
The workspace is assigned to the module scope cache variable and the timestamp is recorded.
- Source
JSON Workspace.
- Type:
- workspace
(inner) checkWorkspaceCache(forceopt) → {workspace}
The method checks whether the module scope variable cache has been populated.
The timestamp set by cacheWorkspace is checked against the current time. The [workspace] cache will be invalidated if the difference exceeds the WORKSPACE_AGE environment variable.
Setting the WORKSPACE_AGE to 0 is not recommended as this could cause the cache to be flushed while a request is passed through the XYZ API. A layer query processed by the Query API module will request the layer and associated locale which could be defined in remote templates. Each request to the Workspace API getTemplate method for the locale, layer, and query templates will call the checkWorkspaceCache method which will cause the workspace to be flushed and templates previously cached from their src no longer available.
The cacheWorkspace method is called if the cache is invalid.
Name | Type | Attributes | Description |
---|---|---|---|
force | Boolean | <optional> | The workspace cache will be cleared with the force param flag. |
- Source
JSON Workspace.
- Type:
- workspace
(inner) mark_template(templates_object) → {Object}
The method maps the Object.entries of the templates_object param and assigns the _type property on the object marking is a different types of templates.
Name | Type | Description |
---|---|---|
templates_object | Object |
- Source
templates_object with _core: true property.
- Type:
- Object