绘制 redis(键值)数据结构图的标准方法是什么?
What is the standard way to diagram a redis (key-value) data structure?
我正在创建一个 redis(键值)数据库,我希望能够轻松更改表示数据存储方式的图表。
包含在此图表中,我希望能够区分保存为 JSON 字符串的数据与实际上是散列 table 或集合或有序集合的数据。
我尝试在 excel 中写一些东西,但它太像关系数据库了,我尝试在 JSON 中写它,但很难说出 JSON 的值是什么=19=] 字符串,并且是哈希值。
是否有关于如何绘制此图表的行业标准?
编辑:
我最终编写了自己的语法,但仍然想知道答案。
这是我为自己创建的语法:(这是我要制作的纸牌游戏的示例 Redis 结构:http://pastebin.com/4aRye4HQ)
key: = string
#key: = hash
$key: = set
$$key: = sortedSet
这是我用来对语法进行颜色编码的 Sublime 语法高亮文件(另存为 redis.YAML-tmLanguage):
# [PackageDev] target_format: plist, ext: tmLanguage
---
name: Redis
scopeName: source.redis
fileTypes: []
uuid: 0033bdf9-cd9f-4147-bd2e-a9fed3d07e1e
patterns:
- include: '#erb'
- match: \#[A-Za-z][A-Za-z0-9_]+
name: variable.parameter
comment: Hashes
- match: $[A-Za-z][A-Za-z0-9_]+
name: support.constant
comment: Sets
- match: $$[A-Za-z][A-Za-z0-9_]+
name: entity.name.class
comment: Sets
- match: \d+
name: constant.numeric
comment: Numbers
- name: constant.numeric.yaml
match: (?:(?:(-\s*)?(\w+\s*(:)))|(-))\s*((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\s*$
captures:
'1': {name: punctuation.definition.entry.yaml}
'2': {name: entity.name.tag.yaml}
'3': {name: punctuation.separator.key-value.yaml}
'4': {name: punctuation.definition.entry.yaml}
- name: string.unquoted.yaml
match: (?:(?:(-\s*)?(\w+\s*(:)))|(-))\s*(?:((")[^"]*("))|((')[^']*('))|([^,{}&#\[\]]+))\s*
captures:
'1': {name: punctuation.definition.entry.yaml}
'2': {name: entity.name.tag.yaml}
'3': {name: punctuation.separator.key-value.yaml}
'4': {name: punctuation.definition.entry.yaml}
'5': {name: string.quoted.double.yaml}
'6': {name: punctuation.definition.string.begin.yaml}
'7': {name: punctuation.definition.string.end.yaml}
'8': {name: string.quoted.single.yaml}
'9': {name: punctuation.definition.string.begin.yaml}
'10': {name: punctuation.definition.string.end.yaml}
'11': {name: string.unquoted.yaml}
- name: constant.other.date.yaml
match: (?:(?:(-\s*)?(\w+\s*(:)))|(-))\s*([0-9]{4}-[0-9]{2}-[0-9]{2})\s*$
captures:
'1': {name: punctuation.definition.entry.yaml}
'2': {name: entity.name.tag.yaml}
'3': {name: punctuation.separator.key-value.yaml}
'4': {name: punctuation.definition.entry.yaml}
- include: '#value'
repository:
array:
name: meta.structure.array.json
begin: \[
beginCaptures:
'0': {name: punctuation.definition.array.begin.json}
end: \]
endCaptures:
'0': {name: punctuation.definition.array.end.json}
patterns:
- include: '#value'
- name: punctuation.separator.array.json
match: ','
- name: invalid.illegal.expected-array-separator.json
match: '[^\s\]]'
comments:
patterns:
- name: comment.block.documentation.json
begin: /\*\*
end: \*/
captures:
'0': {name: punctuation.definition.comment.json}
- name: comment.block.json
begin: /\*
end: \*/
captures:
'0': {name: punctuation.definition.comment.json}
- name: comment.line.double-slash.js
match: (//).*$\n?
captures:
'1': {name: punctuation.definition.comment.json}
constant:
name: constant.language.json
match: \b(?:true|false|null)\b
number:
comment: handles integer and decimal numbers
name: constant.numeric.json
match: "(?x: # turn on extended mode\n\t\t\t -? #\
\ an optional minus\n\t\t\t (?:\n\t\t\t 0 #\
\ a zero\n\t\t\t | # ...or...\n\t\t\t [1-9]\
\ # a 1-9 character\n\t\t\t \d* # followed by zero or\
\ more digits\n\t\t\t )\n\t\t\t (?:\n\t\t\t \
\ (?:\n\t\t\t \. # a period\n\t\t\t \
\ \d+ # followed by one or more digits\n\t\t\t )?\n\t\t\
\t (?:\n\t\t\t [eE] # an e character\n\t\t\t\
\ [+-]? # followed by an option +/-\n\t\t\t \
\ \d+ # followed by one or more digits\n\t\t\t )? #\
\ make exponent optional\n\t\t\t )? # make decimal portion\
\ optional\n\t\t\t )"
object:
comment: a JSON object
name: meta.structure.dictionary.json
begin: \{
beginCaptures:
'0': {name: punctuation.definition.dictionary.begin.json}
end: \}
endCaptures:
'0': {name: punctuation.definition.dictionary.end.json}
patterns:
- comment: the JSON object key
include: '#string'
- include: '#comments'
- name: meta.structure.dictionary.value.json
begin: ':'
beginCaptures:
'0': {name: punctuation.separator.dictionary.key-value.json}
end: (,)|(?=\})
endCaptures:
'1': {name: punctuation.separator.dictionary.pair.json}
patterns:
- comment: the JSON object value
include: '#value'
- name: invalid.illegal.expected-dictionary-separator.json
match: '[^\s,]'
- name: invalid.illegal.expected-dictionary-separator.json
match: '[^\s\}]'
string:
name: string.quoted.double.json
begin: '"'
beginCaptures:
'0': {name: punctuation.definition.string.begin.json}
end: '"'
endCaptures:
'0': {name: punctuation.definition.string.end.json}
patterns:
- name: constant.character.escape.json
match: |-
(?x: # turn on extended mode
\ # a literal backslash
(?: # ...followed by...
["\/bfnrt] # one of these characters
| # ...or...
u # a u
[0-9a-fA-F]{4} # and four hex digits
)
)
- name: invalid.illegal.unrecognized-string-escape.json
match: \.
value:
comment: "the 'value' diagram at http://json.org"
patterns:
- include: '#constant'
- include: '#number'
- include: '#string'
- include: '#array'
- include: '#object'
- include: '#comments'
foldingStartMarker: |-
(?x: # turn on extended mode
^ # a line beginning with
\s* # some optional space
[{\[] # the start of an object or array
(?! # but not followed by
.* # whatever
[}\]] # and the close of an object or array
,? # an optional comma
\s* # some optional space
$ # at the end of the line
)
| # ...or...
[{\[] # the start of an object or array
\s* # some optional space
$ # at the end of the line
)
foldingStopMarker: |-
(?x: # turn on extended mode
^ # a line beginning with
\s* # some optional space
[}\]] # and the close of an object or array
)
keyEquivalent: ^~J
...
我正在创建一个 redis(键值)数据库,我希望能够轻松更改表示数据存储方式的图表。 包含在此图表中,我希望能够区分保存为 JSON 字符串的数据与实际上是散列 table 或集合或有序集合的数据。
我尝试在 excel 中写一些东西,但它太像关系数据库了,我尝试在 JSON 中写它,但很难说出 JSON 的值是什么=19=] 字符串,并且是哈希值。
是否有关于如何绘制此图表的行业标准?
编辑: 我最终编写了自己的语法,但仍然想知道答案。
这是我为自己创建的语法:(这是我要制作的纸牌游戏的示例 Redis 结构:http://pastebin.com/4aRye4HQ)
key: = string
#key: = hash
$key: = set
$$key: = sortedSet
这是我用来对语法进行颜色编码的 Sublime 语法高亮文件(另存为 redis.YAML-tmLanguage):
# [PackageDev] target_format: plist, ext: tmLanguage
---
name: Redis
scopeName: source.redis
fileTypes: []
uuid: 0033bdf9-cd9f-4147-bd2e-a9fed3d07e1e
patterns:
- include: '#erb'
- match: \#[A-Za-z][A-Za-z0-9_]+
name: variable.parameter
comment: Hashes
- match: $[A-Za-z][A-Za-z0-9_]+
name: support.constant
comment: Sets
- match: $$[A-Za-z][A-Za-z0-9_]+
name: entity.name.class
comment: Sets
- match: \d+
name: constant.numeric
comment: Numbers
- name: constant.numeric.yaml
match: (?:(?:(-\s*)?(\w+\s*(:)))|(-))\s*((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\s*$
captures:
'1': {name: punctuation.definition.entry.yaml}
'2': {name: entity.name.tag.yaml}
'3': {name: punctuation.separator.key-value.yaml}
'4': {name: punctuation.definition.entry.yaml}
- name: string.unquoted.yaml
match: (?:(?:(-\s*)?(\w+\s*(:)))|(-))\s*(?:((")[^"]*("))|((')[^']*('))|([^,{}&#\[\]]+))\s*
captures:
'1': {name: punctuation.definition.entry.yaml}
'2': {name: entity.name.tag.yaml}
'3': {name: punctuation.separator.key-value.yaml}
'4': {name: punctuation.definition.entry.yaml}
'5': {name: string.quoted.double.yaml}
'6': {name: punctuation.definition.string.begin.yaml}
'7': {name: punctuation.definition.string.end.yaml}
'8': {name: string.quoted.single.yaml}
'9': {name: punctuation.definition.string.begin.yaml}
'10': {name: punctuation.definition.string.end.yaml}
'11': {name: string.unquoted.yaml}
- name: constant.other.date.yaml
match: (?:(?:(-\s*)?(\w+\s*(:)))|(-))\s*([0-9]{4}-[0-9]{2}-[0-9]{2})\s*$
captures:
'1': {name: punctuation.definition.entry.yaml}
'2': {name: entity.name.tag.yaml}
'3': {name: punctuation.separator.key-value.yaml}
'4': {name: punctuation.definition.entry.yaml}
- include: '#value'
repository:
array:
name: meta.structure.array.json
begin: \[
beginCaptures:
'0': {name: punctuation.definition.array.begin.json}
end: \]
endCaptures:
'0': {name: punctuation.definition.array.end.json}
patterns:
- include: '#value'
- name: punctuation.separator.array.json
match: ','
- name: invalid.illegal.expected-array-separator.json
match: '[^\s\]]'
comments:
patterns:
- name: comment.block.documentation.json
begin: /\*\*
end: \*/
captures:
'0': {name: punctuation.definition.comment.json}
- name: comment.block.json
begin: /\*
end: \*/
captures:
'0': {name: punctuation.definition.comment.json}
- name: comment.line.double-slash.js
match: (//).*$\n?
captures:
'1': {name: punctuation.definition.comment.json}
constant:
name: constant.language.json
match: \b(?:true|false|null)\b
number:
comment: handles integer and decimal numbers
name: constant.numeric.json
match: "(?x: # turn on extended mode\n\t\t\t -? #\
\ an optional minus\n\t\t\t (?:\n\t\t\t 0 #\
\ a zero\n\t\t\t | # ...or...\n\t\t\t [1-9]\
\ # a 1-9 character\n\t\t\t \d* # followed by zero or\
\ more digits\n\t\t\t )\n\t\t\t (?:\n\t\t\t \
\ (?:\n\t\t\t \. # a period\n\t\t\t \
\ \d+ # followed by one or more digits\n\t\t\t )?\n\t\t\
\t (?:\n\t\t\t [eE] # an e character\n\t\t\t\
\ [+-]? # followed by an option +/-\n\t\t\t \
\ \d+ # followed by one or more digits\n\t\t\t )? #\
\ make exponent optional\n\t\t\t )? # make decimal portion\
\ optional\n\t\t\t )"
object:
comment: a JSON object
name: meta.structure.dictionary.json
begin: \{
beginCaptures:
'0': {name: punctuation.definition.dictionary.begin.json}
end: \}
endCaptures:
'0': {name: punctuation.definition.dictionary.end.json}
patterns:
- comment: the JSON object key
include: '#string'
- include: '#comments'
- name: meta.structure.dictionary.value.json
begin: ':'
beginCaptures:
'0': {name: punctuation.separator.dictionary.key-value.json}
end: (,)|(?=\})
endCaptures:
'1': {name: punctuation.separator.dictionary.pair.json}
patterns:
- comment: the JSON object value
include: '#value'
- name: invalid.illegal.expected-dictionary-separator.json
match: '[^\s,]'
- name: invalid.illegal.expected-dictionary-separator.json
match: '[^\s\}]'
string:
name: string.quoted.double.json
begin: '"'
beginCaptures:
'0': {name: punctuation.definition.string.begin.json}
end: '"'
endCaptures:
'0': {name: punctuation.definition.string.end.json}
patterns:
- name: constant.character.escape.json
match: |-
(?x: # turn on extended mode
\ # a literal backslash
(?: # ...followed by...
["\/bfnrt] # one of these characters
| # ...or...
u # a u
[0-9a-fA-F]{4} # and four hex digits
)
)
- name: invalid.illegal.unrecognized-string-escape.json
match: \.
value:
comment: "the 'value' diagram at http://json.org"
patterns:
- include: '#constant'
- include: '#number'
- include: '#string'
- include: '#array'
- include: '#object'
- include: '#comments'
foldingStartMarker: |-
(?x: # turn on extended mode
^ # a line beginning with
\s* # some optional space
[{\[] # the start of an object or array
(?! # but not followed by
.* # whatever
[}\]] # and the close of an object or array
,? # an optional comma
\s* # some optional space
$ # at the end of the line
)
| # ...or...
[{\[] # the start of an object or array
\s* # some optional space
$ # at the end of the line
)
foldingStopMarker: |-
(?x: # turn on extended mode
^ # a line beginning with
\s* # some optional space
[}\]] # and the close of an object or array
)
keyEquivalent: ^~J
...