Documentation | 2025.1

# Cache: Swarm Cache

From Swarm 2022.2, Swarm no longer supports APIs older than v9.

## Swarm config cache file delete

Alternatively, use the Cache Info tab of the System Information page. Navigate to the User id dropdown menu, select System Information, and click the Cache Info tab. For more information, see Cache Info.

### Summary

Introduced for Swarm 2019.2 and later, deletes the Swarm configuration cache files and restarts the workers.

DELETE /api/v9/cache/config/

### Description

Used to delete the Swarm configuration cache files after the Swarm configuration or custom modules have changed. When workers complete their current tasks they are automatically restarted so that they use the new Swarm configuration and custom modules for their next tasks.

Only admin users can delete the Swarm configuration cache.

### Example response

#### When cache files are not deleted and workers are not shutdown:

For example, this can happen if you make the call and then make the same call again before the cache files have rebuilt.

    HTTP/1.1 200 OK

    {
        "isValid":true,
        "messages":[
            "File <SWARM_ROOT>/data/cache/module-config-cache.php was not deleted",
            "File <SWARM_ROOT>/data/cache/module-classmap-cache.php was not deleted"
        ]
    }

### Example of usage

It might also be possible to use a password in place of the ticket if your Helix Core Server allows it.

curl -u "username:ticket" -X DELETE "https://myswarm.url/api/v9/cache/config/"

Assuming that the authenticated user has permission, Swarm responds with the cache deleted and workers shutdown messages:

    HTTP/1.1 200 OK

    {
        "isValid":true,
        "messages":[
            "File <SWARM_ROOT>/data/cache/module-config-cache.php deleted",
            "File <SWARM_ROOT>/data/cache/module-classmap-cache.php deleted",
            "Workers are shutdown. They will start automatically by recurring task"
        ]
    }

## Verify Redis cache

Alternatively, use the Cache Info tab of the System Information page. Navigate to the User id dropdown menu, select System Information, and click the Cache Info tab. For more information, see Cache Info.

### Summary

Introduced for Swarm 2019.2 and later, verifies the Swarm Redis cache.

POST /serverid/api/v9/cache/redis/verify?context=user,group,project,workflow

### Description

The data in the Redis cache for groups, users, projects, and workflows should be the same as the data held by the Helix Core Server. However, in some circumstances, such as when changes are made in the Helix Core Server when Swarm is down or if errors occur during updates, the Redis cache can get out of sync with the Helix Core Server.

Used to verify the content of the Redis cache. Use the context parameter to verify specific areas of the Redis cache, if no context is specified the entire Redis cache is verified. If a verification finds an out of sync cache file, Swarm automatically updates the data in that cache.

Only admin users can verify the Redis cache.

### Parameters

Parameter | Description | Type | Parameter Type | Required | Default Value
--- | --- | --- | --- | --- | ---
serverid | If Swarm is connected to multiple Helix Core Servers, serverid specifies which Helix Core Server the cache should be verified for. | string | path | See description |
context | Add context to the call to verify a specific area of the Redis cache: No context specified, verifies all of the Redis caches. user verifies the Redis user cache. group verifies the Redis group cache. project verifies the Redis project cache. workflow verifies the Redis workflow cache. To verify multiple areas of cache, separate the entries with a comma , | string | path | No |

### Example usage

It might also be possible to use a password in place of the ticket if your Helix Core Server allows it.

To start verification of the user and group caches:

curl -u "username:ticket" -X POST "https://myswarm.url/api/v9/cache/redis/verify?context=user,group"

JSON response

    HTTP/1.1 200 OK

    {
        isValid: true,
        data: {
            user: {
                state: "Queued",
                progress: false
            },
            group: {
                state: "Queued",
                progress: false
            }
        },
        messages: {
            "Verifying Redis cache for [user,group]"
        }
    }

## Check progress of Redis cache verification

Alternatively, use the Cache Info tab of the System Information page. Navigate to the User id dropdown menu, select System Information, and click the Cache Info tab. For more information, see Cache Info.

### Summary

Introduced for Swarm 2019.2 and later, check progress of the Swarm Redis cache verification.

GET /serverid/api/v9/cache/redis/verify?context=user,group,project,workflow

### Description

Used to check the progress of Redis cache verification process. Use the context parameter to check verification of specific areas of the Redis cache, if no context is specified progress is checked for all areas of the entire Redis cache.

### Parameters

Parameter | Description | Type | Parameter Type | Required | Default Value
--- | --- | --- | --- | --- | ---
serverid | If Swarm is connected to multiple Helix Core Servers, serverid specifies which Helix Core Server cache verification is being checked for. | string | path | See description |
context | Add context to the check verification progress for a specific area of the Redis cache: No context specified, checks verification progress for all of the Redis caches. user checks verification progress for the Redis user cache. group checks verification progress for the Redis group cache. project checks verification progress for the Redis project cache. workflow checks verification progress for the Redis workflow cache. To check the verification progress for multiple areas of cache, separate the entries with a comma , | string | path | No |

### Example usage

It might also be possible to use a password in place of the ticket if your Helix Core Server allows it.

To check verification progress for the user and group caches:

curl -u "username:ticket" "http://myswarm.url/api/v9/cache/redis/verify?context=user,group"

JSON response

    HTTP/1.1 200 OK

    {
        isValid: true,
        data: {
            user: {
                state: "Running",
                progress: "Step 2 of 5; Calculating checksums for Redis keys"
            },
            group: {
                state: "Running",
                progress: "Step 1 of 5; Getting Redis cache entries"
            }
        }
    }

- Valid states for verify are; Not Queued, Queued, Running, and Failed.
- Valid states for progress are, Step x of y; (where x is the current step and y is the total number of steps) followed by:

- Getting Redis cache entries
- Calculating checksums for Redis keys
- Calculating checksums for Perforce models
- Clearing any extraneous Redis cache entries
- Indexing any missing Perforce models into the Redis cache
- Verification complete

## Redis cache delete

### Summary

Introduced for Swarm 2019.2 and later, deletes the Swarm Redis cache.

DELETE /serverid/api/v9/cache/redis?context=user,group,project,workflow

### Description

Used to delete the Redis cache. Use the context parameter to delete specific areas of the Redis cache, if no context is specified the entire Redis cache is deleted.

Only admin users can delete the Redis cache.

### Parameters

Parameter | Description | Type | Parameter Type | Required | Default Value
--- | --- | --- | --- | --- | ---
serverid | If Swarm is connected to multiple Helix Core Servers, serverid specifies which Helix Core Server the cache should be deleted for. | string | path | See description |
context | Add context to the call to delete a specific area of the Redis cache: No context specified, deletes all of the Redis caches. user deletes the Redis user cache. group deletes the Redis group cache. project deletes the Redis project cache. workflow deletes the Redis workflow cache. To delete multiple areas of cache, separate the entries with a comma , | string | path | No |

### Example response

#### When an invalid Redis cache context is specified:

If an invalid context is specified in the call:

    HTTP/1.1 200 OK

    {
        "isValid":true,
        "messages":[
            "Invalid context [usr], must contain only [user, group, project, workflow]",
        ]
    }

### Example of usage

It might also be possible to use a password in place of the ticket if your Helix Core Server allows it.

curl -u "username:ticket" -X DELETE "https://myswarm.url/serverA/api/v9/cache/redis?context=user,group"

Assuming that the authenticated user has permission, Swarm responds with the cache deleted message:

    HTTP/1.1 200 OK

    {
        "isValid":true,
        "messages":[
            "Deleted key(s) [Swarm^serverA:user-populated-status, Swarm^serverA:group-populated-status]",
        ]
    }

Your search for returned results