salt.modules.redis

Module to provide redis functionality to Salt

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 范例:

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

Asynchronously save the dataset to disk

命令行接口CLI 范例:

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

Get redis server configuration values

命令行接口CLI 范例:

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 范例:

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 范例:

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

Deletes the keys from redis, returns number of keys deleted

命令行接口CLI 范例:

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 范例:

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 范例:

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 范例:

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

Remove all keys from all databases

命令行接口CLI 范例:

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

Remove all keys from the selected database

命令行接口CLI 范例:

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

Get redis key value

命令行接口CLI 范例:

salt '*' redis.get_key foo
salt.modules.redismod.get_master_ip(host=None, port=None, password=None)

Get host information about slave

命令行接口CLI 范例:

salt '*' redis.get_master_ip
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 范例:

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 范例:

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 范例:

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

Get redis key type

命令行接口CLI 范例:

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 范例:

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 范例:

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 范例:

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 范例:

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 范例:

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

Synchronously save the dataset to disk

命令行接口CLI 范例:

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

Get ip for sentinel master

命令行接口CLI 范例:

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

Set redis key value

命令行接口CLI 范例:

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 范例:

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 范例:

# 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 范例:

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 范例:

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 范例:

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 范例:

salt '*' redis.zrange foo_sorted 0 10