# salt.cache.consul

Minion data cache plugin for Consul key/value data store.

Added in version 2016.11.2.

Changed in version 3005: Timestamp/cache updated support added.

depends:

  python-consul >= 0.2.0

It is up to the system administrator to set up and configure the Consul infrastructure. All is needed for this plugin is a working Consul agent with a read-write access to the key-value store.

The related documentation can be found in the Consul documentation.

To enable this cache plugin, the master will need the python client for Consul installed. This can be easily installed with pip:

    pip install python-consul

Optionally, depending on the Consul agent configuration, the following values could be set in the master config. These are the defaults:

    consul.host: 127.0.0.1
    consul.port: 8500
    consul.token: None
    consul.scheme: http
    consul.consistency: default
    consul.dc: dc1
    consul.verify: True
    consul.timestamp_suffix: .tstamp  # Added in 3005.0

In order to bring the cache APIs into conformity, in 3005.0 timestamp information gets stored as a separate `{key}.tstamp` key/value. If your existing functionality depends on being able to store normal keys with the `.tstamp` suffix, override the `consul.timestamp_suffix` default config.

Related docs could be found in the python-consul documentation.

To use the consul as a minion data cache backend, set the master `cache` config value to `consul`:

    cache: consul

salt.cache.consul.contains(bank, key)

  Checks if the specified bank contains the specified key.

salt.cache.consul.fetch(bank, key)

  Fetch a key value.

salt.cache.consul.flush(bank, key=None)

  Remove the key from the cache bank with all the key content.

salt.cache.consul.list_(bank)

  Return an iterable object containing all entries stored in the specified bank.

salt.cache.consul.store(bank, key, data)

  Store a key value.

salt.cache.consul.updated(bank, key)

  Return the Unix Epoch timestamp of when the key was last updated. Return None if key is not found.