Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain the WORKSPACE AGE in more detail #1628

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mod/workspace/_workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ function roles(req, res) {
@description
The workspace/test method which is only available to user with admin credentials requests all locales in workspace.

The cached workspace will be flushed for the test method.

Requesting all locales should add any additional templates to the workspace.

The test method will iterate over all workspace.templates and get from the getTemplate method to check whether any errors are logged on a template in regards to its src parameter.
Expand Down
5 changes: 4 additions & 1 deletion mod/workspace/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const getFrom = require('../provider/getFrom')

const merge = require('../utils/merge')

// Assign default age in ms.
process.env.WORKSPACE_AGE ??= 3600000

let cache = null
Expand All @@ -28,7 +29,9 @@ const logger = require('../utils/logger')
@description
The method checks whether the module scope variable cache has been populated.

The age of the cached timestamp is checked against the WORKSPACE_AGE environment variable.
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]{@link module:/query~layerQuery} will request the layer and associated locale which could be defined in remote templates. Each request to the [Workspace API getTemplate]{@link module:/workspace/getTemplate~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.

Expand Down
2 changes: 1 addition & 1 deletion mod/workspace/getTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const envReplace = require('../utils/envReplace')
@async

@description
The workspace will be requested from the workspace/cache module.
The workspace will checked and cached by the [Workspace API checkWorkspaceCache]{@link module:/workspace/cache~checkWorkspaceCache} method.

A template object matching the template_key param in the workspace.templates{} object will be returned from the getTemplate method.

Expand Down
Loading