我正在寻找一种在redis中实现分层文件/文件夹树的有效方法,并且能够轻松地移动节点。
/
a/
a1
a2
b/
b1
b2
c/
c1
x/
x1
y/
y1
我想存储上面的树,并且很容易进行
等操作move node /a/b/c to /foo/a/b/c
move node /a/b/c to /x/c
delete node /a/b
指向现有实施模型等会有所帮助。
答案 0 :(得分:7)
我设计的架构可以帮助人们轻松添加,移动和重命名节点和条目
# **enode** a hierarchical directory in redis
# A folder/node structure where nodes can have sub-nodes and entries.
# Entries can have tags.
#
# Each entry gets an enodeid and an entryid
# enodeid - The id of the directory that contains the entry
# entryid - The id of this entry within this enode/directory
#
# The data schema is as follows
# enodeid:kids - Sorted set containing the kids for each directory
# The topmost node is a string "root" and not a number
# The sort score is actually the enodeid of the corresponding kid
# so if /a has an enodeid of 2 and is a kid of root the entry is
# root:kids [2, "a"]
# If a directory /a/b exists and has an enodeid of 4 than
# 2:kids = [4, "b"] - here 2 is the enodeid of '/a'
#
# enodeid:meta - Hash entry containing the name and parent of an enodeid
# 2:meta = {name: "a", parentid: "root"}
# 4:meta = {name: "b", parentid: 2}
#
# enode.next.id - Unique enode id's
#
# entry.next.id - Unique entry id's
#
# enodeid:entries - Sorted set containing the entries in a directory
# The sort score is the sequence number of the entry withi the directory
# moveEntry moves the entry up/down within this
#
# enodeid.entry.num - Unique entry id's for a given enodeid
#
# enodeid:tags - Sorted list of tags
# Score is tagcount, memeber is tag
#
# enodeid:axs - List of usernames that have access to this folder