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: 'salt' redis.port: 6379 redis.db: 0 redis.password: None
Asynchronously rewrite the append-only file
CLI Example:
salt '*' redis.bgrewriteaof
Asynchronously save the dataset to disk
CLI Example:
salt '*' redis.bgsave
Get redis server configuration values
CLI Example:
salt '*' redis.config_get salt '*' redis.config_get port
Set redis server configuration values
CLI Example:
salt '*' redis.config_set masterauth luv_kittens
Return the number of keys in the selected database
CLI Example:
salt '*' redis.dbsize
Deletes the keys from redis, returns number of keys deleted
CLI Example:
salt '*' redis.delete foo
Return true if the key exists in redis
CLI Example:
salt '*' redis.exists foo
Set a keys time to live in seconds
CLI Example:
salt '*' redis.expire foo 300
Set a keys expire at given UNIX time
CLI Example:
salt '*' redis.expireat foo 1400000000
Remove all keys from all databases
CLI Example:
salt '*' redis.flushall
Remove all keys from the selected database
CLI Example:
salt '*' redis.flushdb
Get redis key value
CLI Example:
salt '*' redis.get_key foo
Get host information about slave
CLI Example:
salt '*' redis.get_master_ip
Delete one of more hash fields.
New in version 2017.7.0.
CLI Example:
salt '*' redis.hdel foo_hash bar_field1 bar_field2
Determine if a hash fields exists.
New in version 2017.7.0.
CLI Example:
salt '*' redis.hexists foo_hash bar_field
Get specific field value from a redis hash, returns dict
CLI Example:
salt '*' redis.hget foo_hash bar_field
Get all fields and values from a redis hash, returns dict
CLI Example:
salt '*' redis.hgetall foo_hash
Increment the integer value of a hash field by the given number.
New in version 2017.7.0.
CLI Example:
salt '*' redis.hincrby foo_hash bar_field 5
Increment the float value of a hash field by the given number.
New in version 2017.7.0.
CLI Example:
salt '*' redis.hincrbyfloat foo_hash bar_field 5.17
Returns number of fields of a hash.
New in version 2017.7.0.
CLI Example:
salt '*' redis.hlen foo_hash
Returns the values of all the given hash fields.
New in version 2017.7.0.
CLI Example:
salt '*' redis.hmget foo_hash bar_field1 bar_field2
Sets multiple hash fields to multiple values.
New in version 2017.7.0.
CLI Example:
salt '*' redis.hmset foo_hash bar_field1=bar_value1 bar_field2=bar_value2
Incrementally iterate hash fields and associated values.
New in version 2017.7.0.
CLI Example:
salt '*' redis.hscan foo_hash match='field_prefix_*' count=1
Set the value of a hash field.
New in version 2017.7.0.
CLI Example:
salt '*' redis.hset foo_hash bar_field bar_value
Set the value of a hash field only if the field does not exist.
New in version 2017.7.0.
CLI Example:
salt '*' redis.hsetnx foo_hash bar_field bar_value
Return all the values in a hash.
New in version 2017.7.0.
CLI Example:
salt '*' redis.hvals foo_hash bar_field1 bar_value1
Get information and statistics about the server
CLI Example:
salt '*' redis.info
Get redis key type
CLI Example:
salt '*' redis.type foo
Get redis keys, supports glob style patterns
CLI Example:
salt '*' redis.keys salt '*' redis.keys test*
Get the UNIX time in seconds of the last successful save to disk
CLI Example:
salt '*' redis.lastsave
Get the length of a list in Redis
CLI Example:
salt '*' redis.llen foo_list
Get a range of values from a list in Redis
CLI Example:
salt '*' redis.lrange foo_list 0 10
Ping the server, returns False on connection errors
CLI Example:
salt '*' redis.ping
Synchronously save the dataset to disk
CLI Example:
salt '*' redis.save
Get ip for sentinel master
CLI Example:
salt '*' redis.sentinel_get_master_ip 'mymaster'
Set redis key value
CLI Example:
salt '*' redis.set_key foo bar
Synchronously save the dataset to disk and then shut down the server
CLI Example:
salt '*' redis.shutdown
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
Get members in a Redis set
CLI Example:
salt '*' redis.smembers foo_set
Return the current server UNIX time in seconds
CLI Example:
salt '*' redis.time
Get the length of a sorted set in Redis
CLI Example:
salt '*' redis.zcard foo_sorted
Get a range of values from a sorted set in Redis by index
CLI Example:
salt '*' redis.zrange foo_sorted 0 10
© 2019 SaltStack.
Licensed under the Apache License, Version 2.0.
https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.redismod.html