salt.modules.redis

Module to provide redis functionality to Salt

New in version 2014.7.0.

configuration:This module requires the redis python module and uses the following defaults which may be overridden in the minion configuration:
redis.host: 'localhost'
redis.port: 6379
redis.db: 0
redis.password: None
salt.modules.redismod.bgrewriteaof(host=None, port=None, db=None, password=None)

Asynchronously rewrite the append-only file

CLI Example:

salt '*' redis.bgrewriteaof
salt.modules.redismod.bgsave(host=None, port=None, db=None, password=None)

Asynchronously save the dataset to disk

CLI Example:

salt '*' redis.bgsave
salt.modules.redismod.config_get(pattern='*', host=None, port=None, db=None, password=None)

Get redis server configuration values

CLI Example:

salt '*' redis.config_get
salt '*' redis.config_get port
salt.modules.redismod.config_set(name, value, host=None, port=None, db=None, password=None)

Set redis server configuration values

CLI Example:

salt '*' redis.config_set masterauth luv_kittens
salt.modules.redismod.dbsize(host=None, port=None, db=None, password=None)

Return the number of keys in the selected database

CLI Example:

salt '*' redis.dbsize
salt.modules.redismod.delete(*keys, **connection_args)

Deletes the keys from redis, returns number of keys deleted

CLI Example:

salt '*' redis.delete foo
salt.modules.redismod.exists(key, host=None, port=None, db=None, password=None)

Return true if the key exists in redis

CLI Example:

salt '*' redis.exists foo
salt.modules.redismod.expire(key, seconds, host=None, port=None, db=None, password=None)

Set a keys time to live in seconds

CLI Example:

salt '*' redis.expire foo 300
salt.modules.redismod.expireat(key, timestamp, host=None, port=None, db=None, password=None)

Set a keys expire at given UNIX time

CLI Example:

salt '*' redis.expireat foo 1400000000
salt.modules.redismod.flushall(host=None, port=None, db=None, password=None)

Remove all keys from all databases

CLI Example:

salt '*' redis.flushall
salt.modules.redismod.flushdb(host=None, port=None, db=None, password=None)

Remove all keys from the selected database

CLI Example:

salt '*' redis.flushdb
salt.modules.redismod.get_key(key, host=None, port=None, db=None, password=None)

Get redis key value

CLI Example:

salt '*' redis.get_key foo
salt.modules.redismod.hget(key, field, host=None, port=None, db=None, password=None)

Get specific field value from a redis hash, returns dict

CLI Example:

salt '*' redis.hget foo_hash bar_field
salt.modules.redismod.hgetall(key, host=None, port=None, db=None, password=None)

Get all fields and values from a redis hash, returns dict

CLI Example:

salt '*' redis.hgetall foo_hash
salt.modules.redismod.info(host=None, port=None, db=None, password=None)

Get information and statistics about the server

CLI Example:

salt '*' redis.info
salt.modules.redismod.key_type(key, host=None, port=None, db=None, password=None)

Get redis key type

CLI Example:

salt '*' redis.type foo
salt.modules.redismod.keys(pattern='*', host=None, port=None, db=None, password=None)

Get redis keys, supports glob style patterns

CLI Example:

salt '*' redis.keys
salt '*' redis.keys test*
salt.modules.redismod.lastsave(host=None, port=None, db=None, password=None)

Get the UNIX time in seconds of the last successful save to disk

CLI Example:

salt '*' redis.lastsave
salt.modules.redismod.llen(key, host=None, port=None, db=None, password=None)

Get the length of a list in Redis

CLI Example:

salt '*' redis.llen foo_list
salt.modules.redismod.lrange(key, start, stop, host=None, port=None, db=None, password=None)

Get a range of values from a list in Redis

CLI Example:

salt '*' redis.lrange foo_list 0 10
salt.modules.redismod.ping(host=None, port=None, db=None, password=None)

Ping the server, returns False on connection errors

CLI Example:

salt '*' redis.ping
salt.modules.redismod.save(host=None, port=None, db=None, password=None)

Synchronously save the dataset to disk

CLI Example:

salt '*' redis.save
salt.modules.redismod.set_key(key, value, host=None, port=None, db=None, password=None)

Set redis key value

CLI Example:

salt '*' redis.set_key foo bar
salt.modules.redismod.shutdown(host=None, port=None, db=None, password=None)

Synchronously save the dataset to disk and then shut down the server

CLI Example:

salt '*' redis.shutdown
salt.modules.redismod.slaveof(master_host=None, master_port=None, host=None, port=None, db=None, password=None)

Make the server a slave of another instance, or promote it as master

CLI Example:

# Become slave of redis-n01.example.com:6379
salt '*' redis.slaveof redis-n01.example.com 6379
salt '*' redis.slaveof redis-n01.example.com
# Become master
salt '*' redis.slaveof
salt.modules.redismod.smembers(key, host=None, port=None, db=None, password=None)

Get members in a Redis set

CLI Example:

salt '*' redis.smembers foo_set
salt.modules.redismod.time(host=None, port=None, db=None, password=None)

Return the current server UNIX time in seconds

CLI Example:

salt '*' redis.time
salt.modules.redismod.zcard(key, host=None, port=None, db=None, password=None)

Get the length of a sorted set in Redis

CLI Example:

salt '*' redis.zcard foo_sorted
salt.modules.redismod.zrange(key, start, stop, host=None, port=None, db=None, password=None)

Get a range of values from a sorted set in Redis by index

CLI Example:

salt '*' redis.zrange foo_sorted 0 10