JSON.DEBUG - Amazon ElastiCache (雷迪OSS斯)

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

JSON.DEBUG

報告資訊。支援的子命令如下:

  • MEMORY <key> [path] – 報告 JSON 值的記憶體使用量 (以位元組為單位)。如果未提供,路徑預設為根。

  • FIELDS <key> [path] – 報告指定文件路徑的欄位數目。如果未提供,路徑預設為根。每個非容器 JSON 值都計為一個欄位。物件和陣列遞迴計為每個內含 JSON 值的一個欄位。除根容器外,每個容器值都計為一個附加欄位。

  • HELP – 列印命令的說明訊息。

語法

JSON.DEBUG <subcommand & arguments>

取決於子命令:

MEMORY

  • 如果路徑是增強型語法:

    • 傳回整數陣列,代表每個路徑上的 JSON 值記憶體大小 (以位元組為單位)。

    • 如果 Redis 的 OSS 鍵不存在,則返回一個空數組。

  • 如果路徑是受限語法:

    • 傳回整數、記憶體大小,以及 JSON 值 (以位元組為單位)。

    • 如果 Redis 的 OSS 金鑰不存在,則傳回 null。

FIELDS

  • 如果路徑是增強型語法:

    • 傳回整數陣列,代表每個路徑上的 JSON 值欄位數量。

    • 如果 Redis 的 OSS 鍵不存在,則返回一個空數組。

  • 如果路徑是受限語法:

    • 傳回整數,JSON 值的欄位數量。

    • 如果 Redis 的 OSS 金鑰不存在,則傳回 null。

HELP – 傳回說明訊息的陣列。

範例

增強型路徑語法:

127.0.0.1:6379> JSON.SET k1 . '[1, 2.3, "foo", true, null, {}, [], {"a":1, "b":2}, [1,2,3]]' OK 127.0.0.1:6379> JSON.DEBUG MEMORY k1 $[*] 1) (integer) 16 2) (integer) 16 3) (integer) 19 4) (integer) 16 5) (integer) 16 6) (integer) 16 7) (integer) 16 8) (integer) 50 9) (integer) 64 127.0.0.1:6379> JSON.DEBUG FIELDS k1 $[*] 1) (integer) 1 2) (integer) 1 3) (integer) 1 4) (integer) 1 5) (integer) 1 6) (integer) 0 7) (integer) 0 8) (integer) 2 9) (integer) 3

受限路徑語法:

127.0.0.1:6379> JSON.SET k1 . '{"firstName":"John","lastName":"Smith","age":27,"weight":135.25,"isAlive":true,"address":{"street":"21 2nd Street","city":"New York","state":"NY","zipcode":"10021-3100"},"phoneNumbers":[{"type":"home","number":"212 555-1234"},{"type":"office","number":"646 555-4567"}],"children":[],"spouse":null}' OK 127.0.0.1:6379> JSON.DEBUG MEMORY k1 (integer) 632 127.0.0.1:6379> JSON.DEBUG MEMORY k1 .phoneNumbers (integer) 166 127.0.0.1:6379> JSON.DEBUG FIELDS k1 (integer) 19 127.0.0.1:6379> JSON.DEBUG FIELDS k1 .address (integer) 4 127.0.0.1:6379> JSON.DEBUG HELP 1) JSON.DEBUG MEMORY <key> [path] - report memory size (bytes) of the JSON element. Path defaults to root if not provided. 2) JSON.DEBUG FIELDS <key> [path] - report number of fields in the JSON element. Path defaults to root if not provided. 3) JSON.DEBUG HELP - print help message.