Backed by Redis, Mechanic offers a simple key/value cache store that you can use in your task scripts.

Cache values may be retrieved in task scripts using {{ cache[key] }} .

For developers

This action requires an object with a single root key to define the cache operation, mapped to an object of arguments.

Operations

  • "set" 
  • "del" 

Operation arguments

  • "key"  – required for all operations, must match /^[a-z0-9_:\-\.\/]+$/i 
  • "value"  – required for "set" , may be any JSON value, including arrays and objects

Examples

Set a cache value:

{
  "action": {
    "type": "cache",
    "options": {
      "set": {
        "key": "foobar",
        "value": 5
      }
    }
  }
}

Clear a cache value:

{
  "action": {
    "type": "cache",
    "options": {
      "del": {
        "key": "foobar"
      }
    }
  }
}

Did this answer your question?