3

我正在寻找一种在 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

指向现有实现模型等的指针会有所帮助。

4

1 回答 1

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
于 2013-01-13T23:03:54.407 回答