def string(name, value, expire=None, expireat=None, **connection_args):
 ret = {'name': name, 'changes': {}, 'result': True, 'comment': 'Key already set to defined value'}
 old_key = __salt__['redis.get_key'](name, **connection_args)
 if (old_key != value):
  __salt__['redis.set_key'](name, value, **connection_args)
  ret['changes'][name] = 'Value updated'
  ret['comment'] = 'Key updated to new value'
 if expireat:
  __salt__['redis.expireat'](name, expireat, **connection_args)
  ret['changes']['expireat'] = 'Key expires at {0}'.format(expireat)
 elif expire:
  __salt__['redis.expire'](name, expire, **connection_args)
  ret['changes']['expire'] = 'TTL set to {0} seconds'.format(expire)
 return ret

def string ( name , value , expire = None , expireat = None , ** connection_args ) : ret = { 'name' : name , 'changes' : { } , 'result' : True , 'comment' : 'Key already set to defined value' } old_key = __salt__ [ 'redis.get_key' ] ( name , ** connection_args ) if ( old_key != value ) : __salt__ [ 'redis.set_key' ] ( name , value , ** connection_args ) ret [ 'changes' ] [ name ] = 'Value updated' ret [ 'comment' ] = 'Key updated to new value' if expireat : __salt__ [ 'redis.expireat' ] ( name , expireat , ** connection_args ) ret [ 'changes' ] [ 'expireat' ] = 'Key expires at {0}' . format ( expireat ) elif expire : __salt__ [ 'redis.expire' ] ( name , expire , ** connection_args ) ret [ 'changes' ] [ 'expire' ] = 'TTL set to {0} seconds' . format ( expire ) return ret
ensure that the key exists in redis with the value specified name redis key to manage value data to persist in key expire sets time to live for key in seconds expireat sets expiration time for key via unix timestamp .