redis

Module to provide redis functionality to Salt

Added 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: 'salt'
redis.port: 6379
redis.db: 0
redis.password: None
saltext.redis.modules.redismod.__virtual__()[source]

Only load this module if redis python module is installed

saltext.redis.modules.redismod.bgrewriteaof(host=None, port=None, db=None, password=None)[source]

Asynchronously rewrite the append-only file

CLI Example:

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

Asynchronously save the dataset to disk

CLI Example:

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

Get redis server configuration values

CLI Example:

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

Set redis server configuration values

CLI Example:

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

Return the number of keys in the selected database

CLI Example:

salt '*' redis.dbsize
saltext.redis.modules.redismod.delete(*keys, **connection_args)[source]

Deletes the keys from redis, returns number of keys deleted

CLI Example:

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

Return true if the key exists in redis

CLI Example:

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

Set a keys time to live in seconds

CLI Example:

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

Set a keys expire at given UNIX time

CLI Example:

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

Remove all keys from all databases

CLI Example:

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

Remove all keys from the selected database

CLI Example:

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

Get redis key value

CLI Example:

salt '*' redis.get_key foo
saltext.redis.modules.redismod.hdel(key, *fields, **options)[source]

Delete one of more hash fields.

Added in version 2017.7.0.

CLI Example:

salt '*' redis.hdel foo_hash bar_field1 bar_field2
saltext.redis.modules.redismod.hexists(key, field, host=None, port=None, db=None, password=None)[source]

Determine if a hash fields exists.

Added in version 2017.7.0.

CLI Example:

salt '*' redis.hexists foo_hash bar_field
saltext.redis.modules.redismod.hget(key, field, host=None, port=None, db=None, password=None)[source]

Get specific field value from a redis hash, returns dict

CLI Example:

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

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

CLI Example:

salt '*' redis.hgetall foo_hash
saltext.redis.modules.redismod.hincrby(key, field, increment=1, host=None, port=None, db=None, password=None)[source]

Increment the integer value of a hash field by the given number.

Added in version 2017.7.0.

CLI Example:

salt '*' redis.hincrby foo_hash bar_field 5
saltext.redis.modules.redismod.hincrbyfloat(key, field, increment=1.0, host=None, port=None, db=None, password=None)[source]

Increment the float value of a hash field by the given number.

Added in version 2017.7.0.

CLI Example:

salt '*' redis.hincrbyfloat foo_hash bar_field 5.17
saltext.redis.modules.redismod.hlen(key, host=None, port=None, db=None, password=None)[source]

Returns number of fields of a hash.

Added in version 2017.7.0.

CLI Example:

salt '*' redis.hlen foo_hash
saltext.redis.modules.redismod.hmget(key, *fields, **options)[source]

Returns the values of all the given hash fields.

Added in version 2017.7.0.

CLI Example:

salt '*' redis.hmget foo_hash bar_field1 bar_field2
saltext.redis.modules.redismod.hmset(key, **fieldsvals)[source]

Sets multiple hash fields to multiple values.

Added in version 2017.7.0.

CLI Example:

salt '*' redis.hmset foo_hash bar_field1=bar_value1 bar_field2=bar_value2
saltext.redis.modules.redismod.hset(key, field, value, host=None, port=None, db=None, password=None)[source]

Set the value of a hash field.

Added in version 2017.7.0.

CLI Example:

salt '*' redis.hset foo_hash bar_field bar_value
saltext.redis.modules.redismod.hsetnx(key, field, value, host=None, port=None, db=None, password=None)[source]

Set the value of a hash field only if the field does not exist.

Added in version 2017.7.0.

CLI Example:

salt '*' redis.hsetnx foo_hash bar_field bar_value
saltext.redis.modules.redismod.hvals(key, host=None, port=None, db=None, password=None)[source]

Return all the values in a hash.

Added in version 2017.7.0.

CLI Example:

salt '*' redis.hvals foo_hash bar_field1 bar_value1
saltext.redis.modules.redismod.hscan(key, cursor=0, match=None, count=None, host=None, port=None, db=None, password=None)[source]

Incrementally iterate hash fields and associated values.

Added in version 2017.7.0.

CLI Example:

salt '*' redis.hscan foo_hash match='field_prefix_*' count=1
saltext.redis.modules.redismod.info(host=None, port=None, db=None, password=None)[source]

Get information and statistics about the server

CLI Example:

salt '*' redis.info
saltext.redis.modules.redismod.keys(pattern='*', host=None, port=None, db=None, password=None)[source]

Get redis keys, supports glob style patterns

CLI Example:

salt '*' redis.keys
salt '*' redis.keys test*
saltext.redis.modules.redismod.key_type(key, host=None, port=None, db=None, password=None)[source]

Get redis key type

CLI Example:

salt '*' redis.type foo
saltext.redis.modules.redismod.lastsave(host=None, port=None, db=None, password=None)[source]

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

CLI Example:

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

Get the length of a list in Redis

CLI Example:

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

Get a range of values from a list in Redis

CLI Example:

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

Ping the server, returns False on connection errors

CLI Example:

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

Synchronously save the dataset to disk

CLI Example:

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

Set redis key value

CLI Example:

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

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

CLI Example:

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

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
saltext.redis.modules.redismod.smembers(key, host=None, port=None, db=None, password=None)[source]

Get members in a Redis set

CLI Example:

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

Return the current server UNIX time in seconds

CLI Example:

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

Get the length of a sorted set in Redis

CLI Example:

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

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

CLI Example:

salt '*' redis.zrange foo_sorted 0 10
saltext.redis.modules.redismod.sentinel_get_master_ip(master, host=None, port=None, password=None)[source]

Get ip for sentinel master

Added in version 2016.3.0.

CLI Example:

salt '*' redis.sentinel_get_master_ip 'mymaster'
saltext.redis.modules.redismod.get_master_ip(host=None, port=None, password=None)[source]

Get host information about slave

Added in version 2016.3.0.

CLI Example:

salt '*' redis.get_master_ip