tencent cloud

Tencent Cloud Distributed Cache (Redis OSS-Compatible)

JSON Module Family

Download
フォーカスモード
フォントサイズ
最終更新日: 2026-08-11 11:12:00
AI翻訳
The JSON Module (valkey-json) provides native storage and manipulation capabilities for JSON documents. It allows JSON data to be stored, queried, and modified directly as a tree structure. Using JSONPath expressions, such as $.store.book[0].title, you can precisely access any node within nested hierarchies. This module is suitable for scenarios that require flexible JSON structure operations, such as document-based configuration storage, API response caching, and nested object queries. This module is supported starting from Valkey 8.0 and is not part of the Redis core command set. Its core commands can be categorized into the following four types based on their functions:
Document-level read/write
JSON.SET: Sets or updates the JSON value at a specified path, with support for NX/XX conditions.
JSON.GET: Obtains the JSON value(s) for one or more paths.
JSON.DEL: Deletes the node(s) at a specified path.
JSON.MGET: Obtains the values at the same path from multiple keys in batches.
Type and Structure Query
JSON.TYPE: Returns the JSON type (object/array/string/number/boolean/null) of the node at a specified path.
JSON.OBJLEN / JSON.OBJKEYS: Returns the number of fields or the list of field names for an object.
JSON.ARRLEN: Returns the length of an array.
JSON.STRLEN: Returns the length of a string value.
Numeric and String Atomic Operations
JSON.NUMINCRBY / JSON.NUMMULTBY: Performs atomic increment or multiplication operations on a numeric node.
JSON.STRAPPEND: Appends content to the end of a string node.
JSON.TOGGLE: Toggles a Boolean value.
Array Operations
JSON.ARRAPPEND: Appends elements to the end of an array.
JSON.ARRINSERT: Inserts an element at a specified index position.
JSON.ARRPOP: Pops the element at a specified index position.
JSON.ARRTRIM: Trims an array, keeping a specified range.
JSON.ARRINDEX: Finds the index position of an element within an array.
For more information, see the Valkey official documentation: valkey-json module.

Command Support Overview

Basic Read/Write Commands: JSON.SET, JSON.GET, JSON.MGET, JSON.MSET, JSON.DEL (including the alias JSON.FORGET). These commands are used to set/obtain/read in batches/set in batches/delete JSON values within keys. Both the standard architecture and cluster architecture of Valkey 8.0 support them.
String Operation Commands: JSON.STRAPPEND and JSON.STRLEN. These commands are used to append content to JSON strings and obtain string lengths. Both the standard architecture and cluster architecture of Valkey 8.0 support them.
Numeric Operation Commands: JSON.NUMINCRBY and JSON.NUMMULTBY. They are used to perform addition, subtraction, and multiplication operations on JSON numeric values. Both the Valkey 8.0 standard architecture and cluster architecture support them.
Array Operation Commands: JSON.ARRAPPEND, JSON.ARRINDEX, JSON.ARRINSERT, JSON.ARRLEN, JSON.ARRPOP, JSON.ARRTRIM. They are used to append elements to arrays, find element indexes, insert elements, obtain array lengths, pop elements, and trim arrays. Both the Valkey 8.0 standard architecture and cluster architecture support them.
Object Operation Commands: JSON.OBJKEYS, JSON.OBJLEN, and JSON.CLEAR. They are used to obtain object key names, obtain the number of object keys, and clear arrays or objects. Both the Valkey 8.0 standard architecture and cluster architecture support them.
Type and Debug Commands: JSON.TYPE, JSON.TOGGLE, JSON.RESP, and JSON.DEBUG. They are used to obtain value types, toggle Boolean values, return JSON values in RESP format, and debug information. (The KEYTABLE-CORRUPT, KEYTABLE-CLEAR, and KEYTABLE-DISTRIBUTION subcommands of JSON.DEBUG require json.debug-mode to be enabled when the module is loaded.)
Cross-Slot Restriction: Most commands operate on a single key and follow the standard key routing rules. JSON.MGET and JSON.MSET are multi-key commands. In a cluster architecture, all keys must reside in the same hash Slot (Slot); otherwise, a CROSSSLOT error is triggered. It is recommended to use Hash Tags (for example, {user}:profile and {user}:settings) to ensure that keys in the same group land in the same Slot.

Command Compatibility Matrix

The support status of this command family across different versions and architectures is shown in the table below (✓ indicates supported, ✗ indicates not supported, and — indicates that the command has no cross-slot access scenario).
Command
Valkey 9.0 Standard Architecture
Valkey 9.0 Cluster Architecture
Valkey 8.0 Standard Architecture
Valkey 8.0 Cluster Architecture
Cross-Slot Support in Cluster Architecture
json.set
json.get
json.mget
json.mset
json.del
json.forget
json.strappend
json.strlen
json.numincrby
json.nummultby
json.arrappend
json.arrindex
json.arrinsert
json.arrlen
json.arrpop
json.arrtrim
json.objkeys
json.objlen
json.clear
json.type
json.toggle
json.resp
json.debug

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック