Module Hub Beta

SETRANGERAND

key offset length charset charcase

Generates a random string, starting at ‘offset’ and of length ‘length’. An optional charset may be provided:

  • ALPHA – letters only: a-z
  • DIGIT – digits only: 0-9
  • ALNUM – letters and digits
  • PUNC – all printable characters other than alphanumerics
  • HEX – hexadecimal: a-f, 0-9
  • CURSE – censored profanity (!@#$%^&*?)
  • BINARY – all characters between 0 and 255
  • READABLE – letters only, but more pronounceable
  • TEXT – this is the default, any printable character (union of ALPHA + DIGIT + PUNC)

Additionally, an optional charcase argument can be provided:

  • MIXEDCASE – this is the default, a mix of upper and lower case. Treated as LOWERCASE charcase for HEX andREADABLE charsets.
  • LOWERCASE – uses only lowercase letters
  • UPPERCASE – uses only uppercase letters

Return Value

Integer reply: the length of the String after it was modified.

Examples

redis> SET mykey “Hello World”
OK
redis> SETRANGEAND mykey 6 5 ALPHA MIXEDCASE
(integer) 11
redis> GET mykey
“Hello ReDiS”

© 2017 Redis Labs, Inc. All rights reserved.