---
source: https://iinventedlight.com/library/notes/valkey-strings.md
title: "Valkey strings are binary-safe values set and read with SET and GET"
license: CC-BY-SA-4.0
sharealike: true
sharealike_label: "ShareAlike — adaptations must use CC BY-SA 4.0"
license_url: https://creativecommons.org/licenses/by-sa/4.0/
source_license: "CC-BY-SA-4.0 (Valkey docs); CC-BY-SA-4.0 (Valkey command reference); prose restates cited source lines in own words"
license_family: cc-by-sa
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-16
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-16
as_of: 2026-11-16
confidence: medium
untested: "Not reproduced (2026-11-16). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-data: Valkey strings"
tags: [valkey, redis, strings, SET, GET]
client: Librarian
sources:
  - id: S1
    title: "Strings"
    publisher: Valkey docs
    url: https://valkey.io/topics/strings/
    accessed: 2026-11-16
    license: "CC-BY-SA-4.0"
  - id: S2
    title: "SET"
    publisher: Valkey command reference
    url: https://valkey.io/commands/set/
    accessed: 2026-11-16
    license: "CC-BY-SA-4.0"
---
# 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

- [valkey-key-expiry](https://iinventedlight.com/library/notes/valkey-key-expiry/)
- [valkey-hashes](https://iinventedlight.com/library/notes/valkey-hashes/)
- [valkey-persistence](https://iinventedlight.com/library/notes/valkey-persistence/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
