← All notes

Valkey strings are binary-safe values set and read with SET and GET

Answer: Strings store sequences of bytes, including text, serialized objects, and binary arrays. They are the simplest type of value you can associate with a Valkey key. SET stores a string value and GET retrieves it.

SET and GET

SET performs an assignment. If the key already holds a value, it is overwritten, regardless of its type, even when that value is not a string. A value can't be bigger than 512 MB. SET options include NX, which only sets the key if it does not already exist, and XX, which only sets the key if it already exists. MSET and MGET set or retrieve several keys in one command.

Counters

INCR parses the string value as an integer, increments it by one, and writes the new value. INCR is atomic, so multiple clients incrementing the same key do not race. There are other similar commands like INCRBY, DECR and DECRBY. Most string operations are O(1); range commands such as GETRANGE can be O(n).

See also

Claims

Sources

License: this note is CC BY SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/). Summary by iinventedlight (AI-assisted). Sources: Valkey docs, Strings, CC-BY-SA-4.0 (https://raw.githubusercontent.com/valkey-io/valkey-doc/main/LICENSE); Valkey command reference, SET, CC-BY-SA-4.0 (https://raw.githubusercontent.com/valkey-io/valkey-doc/main/LICENSE). Text was condensed and changed from the originals.

License: CC-BY-SA-4.0 · Summary by iinventedlight (AI-assisted). Sources: Valkey docs, Strings, CC-BY-SA-4.0 (https://raw.githubusercontent.com/valkey-io/valkey-doc/main/LICENSE); Valkey command reference, SET, CC-BY-SA-4.0 (https://raw.githubusercontent.com/valkey-io/valkey-doc/main/LICENSE). · ShareAlike — adaptations must use CC BY-SA 4.0

Cite this

Permanent ID: iil:note:w9twqaks

iinventedlight. 2026. "Valkey strings are binary-safe values set and read with SET and GET." iinventedlight Library, iil:note:w9twqaks, version of 2026-11-16. https://iinventedlight.com/library/notes/valkey-strings/. License: CC-BY-SA-4.0.

@misc{iil_note_w9twqaks,
  author = {{iinventedlight}},
  title = {{Valkey strings are binary-safe values set and read with SET and GET}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-16},
  url = {https://iinventedlight.com/library/notes/valkey-strings/},
  note = {Permanent ID iil:note:w9twqaks. License: CC-BY-SA-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/valkey-strings.md.