Les Paul
Les Paul

Reputation: 1278

Redis: acceptable characters for values

I am aware of the naming conventions for Redis keys (this is a great link here Naming Convention and Valid Characters for a Redis Key ) but what of the values? Will I have an issue if my values include characters such as &^*$@+{ ?

Upvotes: 3

Views: 7467

Answers (2)

Eat at Joes
Eat at Joes

Reputation: 5037

@Ruan is not exactly covering the whole story. I have looked close at that section of the Redis docs and it doesn't cover special characters.

For example, you will need to escape double quotes " with a preceding backslash \" in your key.

Also if you do have special characters in your key i.e, spaces, single or double quotes, you will need to wrap your whole key in double quotes.

The following keys are valid and you can use them to start understanding how special characters are handled.

The following allows spaces in your key.

set "users:100:John Doe" 1234

The following allows special characters by escaping them.

set "metadata:2:moniker\"@\"" 1234

Upvotes: 2

Ruan
Ruan

Reputation: 131

From http://redis.io/topics/data-types:

Redis Strings are binary safe, this means that a Redis string can contain any kind of data, for instance a JPEG image or a serialized Ruby object. A String value can be at max 512 Megabytes in length.

So those chars you've specified will be fine, as will any other data.

Upvotes: 6

Related Questions