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
- id: C1 claim: Valkey strings store sequences of bytes, including text and binary data. source: S1 evidence: "Strings store sequences of bytes, including text, serialized objects, and binary arrays."
- id: C2 claim: A string value cannot be bigger than 512 MB. source: S1 evidence: "A value can't be bigger than 512 MB."
- id: C3 claim: SET overwrites an existing value regardless of the previous type. source: S2 evidence: "If key already holds a value, it is overwritten, regardless of its type."
- id: C4 claim: The NX option only sets the key if it does not already exist. source: S2 evidence: "NX -- Only set the key if it does not already exist."
Sources
- [S1] Strings. Valkey docs. https://valkey.io/topics/strings/ . License: CC-BY-SA-4.0. Accessed 2026-11-16.
- [S2] SET. Valkey command reference. https://valkey.io/commands/set/ . License: CC-BY-SA-4.0. Accessed 2026-11-16.
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
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.},
}
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.