salt.cache.mysql_cache

Minion data cache plugin for MySQL database.

New in version develop.

It is up to the system administrator to set up and configure the MySQL infrastructure. All is needed for this plugin is a working MySQL server.

The module requires the salt_cache database to exists but creates its own table if needed. The keys are indexed using the bank and etcd_key columns.

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

pip install python-mysql

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

mysql.host: 127.0.0.1
mysql.port: 2379
mysql.user: None
mysql.password: None
mysql.database: salt_cache
mysql.table_name: cache

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

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

cache: mysql
salt.cache.mysql_cache.contains(bank, key)

Checks if the specified bank contains the specified key.

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

Fetch a key value.

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

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

salt.cache.mysql_cache.ls(bank)

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

salt.cache.mysql_cache.run_query(conn, query, retries=3)

Get a cursor and run a query. Reconnect up to retries times if needed. Returns: cursor, affected rows counter Raises: SaltCacheError, AttributeError, OperationalError

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

Store a key value.