Option: $ redis-cli -x SET net_services and -i. To the content of the file /etc/services from a local file system, use the -x For example, in order to set the Redis key net_services One is to use the target payload as the last argumentįrom stdin. There are two ways you can use redis-cli in order to receive input from otherĬommands via the standard input. You can specify a certificate and a corresponding private key using -cert and If the target server requires authentication using a client side certificate, cacertdir to configure a trusted root certificate bundle or directory. You may enable SSL/TLS using the -tls option, along with -cacert or Option and the URI pattern $ redis-cli -u PINGīy default, redis-cli uses a plain TCP connection to connect to Redis. Some or all of this information can also be provided by using the -u Other than the default number zero by using the -n option: $ redis-cli FLUSHALL NOTE: For security reasons, provide the password to redis-cli automatically via theįinally, it's possible to send a command that operates on a database number Perform authentication saving the need of explicitly using the AUTH command: $ redis-cli -a myUnguessablePazzzzzword123 PING If your instance is password protected, the -a option will In order to set a different port, use -p. To specify a different host name or an IP address, use the -h option. You can change the port using several command line options. When you input strings that contain single or double quotes, as you might in passwords, for example, escape the string, like so: 127.0.0.1:6379> AUTH some_admin_user port, password, and databaseīy default, redis-cli connects to the server at the address 127.0.0.1 with port 6379. Single quotes assume the string is literal, and allow only the following escape sequences:įor example, to return Hello World on two lines: 127.0.0.1:6379> SET mykey "Hello\nWorld" \xhh - any ASCII character represented by a hexadecimal number ( hh).Quoted string values are enclosed in double ( ") or single ( ') quotation marks.Įscape sequences are used to put nonprintable characters in character and string literals.Īn escape sequence contains a backslash ( \) symbol followed by one of the escape sequence characters.ĭoubly-quoted strings support the following escape sequences: To input string values that contain whitespaces or non-printable characters, you can use quoted and escaped strings. In interactive mode, a newline sends the command for parsing and execution. When redis-cli parses a command, whitespace characters automatically delimit the arguments. You can force human readable output when writing to a file or in You can force raw outputĮven on the terminal with the -raw option: $ redis-cli -raw INCR mycounter The output is no longer written to the terminal. Note that (integer) is omitted from the output because redis-cli detects For all other outputs it will auto-enable the raw output mode, as in the following example: $ redis-cli INCR mycounter > /tmp/output.txt Redis-cli only shows additional information for human readability when it detects the standard output is a tty, or terminal. This additional information may not be ideal when the output of redis-cli must be used as input of another command or redirected into a file. Since Redis replies are typed (strings, arrays, integers, nil, errors, etc.), you see the type of the reply between parentheses. To run a Redis command and return a standard output at the terminal, include the command to execute as separate arguments of redis-cli: $ redis-cli INCR mycounter This topic covers the different aspects of redis-cli, starting from the simplest and ending with the more advanced features.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |