All Projects → OhBonsai → RedisTree

OhBonsai / RedisTree

Licence: MIT license
Redis Tree (Ploytree) Structure Module

Programming Languages

rust
11053 projects
shell
77523 projects
python
139335 projects - #7 most used programming language
Dockerfile
14818 projects
Makefile
30231 projects

Projects that are alternatives of or similar to RedisTree

Algorithms
Java implementation for Introduction to Algorithms book.
Stars: ✭ 58 (-9.37%)
Mutual labels:  tree, btree
kvstore
KVStore is a simple Key-Value Store based on B+Tree (disk & memory) for Java
Stars: ✭ 88 (+37.5%)
Mutual labels:  tree, btree
terraform-aws-elasticache
Terraform module to create Elasticache Cluster and replica for Redis and Memcache.
Stars: ✭ 19 (-70.31%)
Mutual labels:  module, redis-module
Bplustree
A minimal but extreme fast B+ tree indexing structure demo for billions of key-value storage
Stars: ✭ 1,598 (+2396.88%)
Mutual labels:  tree, btree
Vuejs Tree
A highly customizable and blazing fast Vue tree component ⚡🌲
Stars: ✭ 211 (+229.69%)
Mutual labels:  tree
Fast
Find in AST - Search and refactor code directly in Abstract Syntax Tree as you do with grep for strings
Stars: ✭ 194 (+203.13%)
Mutual labels:  tree
Interview Questions
List of all the Interview questions practiced from online resources and books
Stars: ✭ 187 (+192.19%)
Mutual labels:  tree
Vue Orgchart
It's a simple and direct organization chart plugin. Anytime you want a tree-like chart, you can turn to OrgChart.
Stars: ✭ 182 (+184.38%)
Mutual labels:  tree
mst-persist
Persist and hydrate MobX-state-tree stores (in < 100 LoC)
Stars: ✭ 75 (+17.19%)
Mutual labels:  tree
Libdict
C library of key-value data structures.
Stars: ✭ 234 (+265.63%)
Mutual labels:  tree
Lark
Lark is a parsing toolkit for Python, built with a focus on ergonomics, performance and modularity.
Stars: ✭ 2,916 (+4456.25%)
Mutual labels:  tree
Rrt Algorithms
n-dimensional RRT, RRT* (RRT-Star)
Stars: ✭ 195 (+204.69%)
Mutual labels:  tree
Element Tree Grid
tree grid extends element ui with vue
Stars: ✭ 223 (+248.44%)
Mutual labels:  tree
React Vtree
React component for efficiently rendering large tree structures
Stars: ✭ 185 (+189.06%)
Mutual labels:  tree
Computer Science In Javascript
Computer science reimplemented in JavaScript
Stars: ✭ 2,590 (+3946.88%)
Mutual labels:  tree
Orgchart
It's a simple and direct organization chart plugin. Anytime you want a tree-like chart, you can turn to OrgChart.
Stars: ✭ 2,325 (+3532.81%)
Mutual labels:  tree
Heyui
🎉UI Toolkit for Web, Vue2.0 http://www.heyui.top
Stars: ✭ 2,373 (+3607.81%)
Mutual labels:  tree
Dsladapter
🔥 Kotlin时代的Adapter, Dsl 的形式使用 RecyclerView.Adapter, 支持折叠展开, 树结构,悬停,情感图状态切换, 加载更多, 多类型Item,侧滑菜单等
Stars: ✭ 231 (+260.94%)
Mutual labels:  tree
Fancytree
JavaScript tree view / tree grid plugin with support for keyboard, inline editing, filtering, checkboxes, drag'n'drop, and lazy loading
Stars: ✭ 2,398 (+3646.88%)
Mutual labels:  tree
Domhandler
Handler for htmlparser2, to get a DOM
Stars: ✭ 203 (+217.19%)
Mutual labels:  tree

RedisTree

RedisTree is a Redis module that implements Polytree as a native data type. It allows creating,locating,pushing and detaching tree from Redis keys. RedisTree has been running in production environment for one year

  • 哥,来一趟不容易,点个Star呗
  • Не могли бы вы дать мне звезду ...
  • Could you give me a star...
  • Donne moi une étoile
  • 星をください
  • 나에게 별을 줘

Why?

Store organization data in redis, Need ploytree and some helper function

Quick Start

Docker

# run redis by docker
docker run -p 6379:6379 -d --name redis-redistree ohbonsai/redistree

# exec redis-cli in redis container
docker exec -it redis-redistree /bin/sh
redis-cli

Rust

  • Run cargo build
  • Start a redis server with the redistree module
    • Linux: redis-server --loadmodule ./target/release/libretree.so
    • Mac: redis-server --loadmodule ./target/release/libretree.dylib
  • Open a Redis CLI, and run tree.init hello "a (b (d) c)".

Commands

  • tree.init key tree_value
  • tree.get key
  • tree.del key
  • tree.get_subtree key node_value
  • tree.del_subtree key node_value
  • tree.set_subtree key node_value tree_value
  • tree.get_ancestors key node_value
  • tree.get_descendants key node_value
  • tree.get_father key node_value
  • tree.get_children key node_value

Init Get Del tree from String

    a
  /    \
 b      c
 |
 e

127.0.0.1:6379> tree.init hello "a (b (d) c)"
OK
127.0.0.1:6379> tree.get hello
"a( b( d ) c )"
127.0.0.1:6379> tree.del hello
OK
127.0.0.1:6379> tree.get hello
(nil)
127.0.0.1:6379> tree.init hello "a (("
(error) ERR () is not closed or no root

Fetch Detach

USA government tree

         |----------------------------------USA----------------------------------|
         |                                  |                                    |
    Legislature                      ExecutiveJudiciary                      Judiciary
   /         \                              |                                    |
House      Senate                      WhiteHouse                          SupremeCourt
 |            |                             |                                    |          
Pelosi      Harris                        Biden                               Roberts


127.0.0.1:6379> tree.init usa "USA (Legislature (House (Pelosi) Senate (Harris))ExecutiveJudiciary (WhiteHouse (Biden))Judiciary (SupremeCourt (Roberts)))"
OK

# Get subtree of executive judiciary
127.0.0.1:6379> tree.get_subtree usa ExecutiveJudiciary
"ExecutiveJudiciary( WhiteHouse( Biden ) )"

# Add secretary for Biden
127.0.0.1:6379> tree.set_subtree usa Biden "Blinken"
OK
# now biden has secretary
127.0.0.1:6379> tree.get_subtree usa Biden
"Biden( Blinken )"

# Detach Blinken from Biden
127.0.0.1:6379> tree.del_subtree usa Blinken
"Blinken"
127.0.0.1:6379> tree.get_subtree usa Biden
"Biden"


# Get Harris ancestors 
127.0.0.1:6379> tree.get_ancestors usa Harris
1) "Senate"
2) "Legislature"
3) "USA"

# Get Harris Father node
127.0.0.1:6379> tree.get_father usa Harris
"Senate"

# Get Legislature Children 
127.0.0.1:6379> tree.get_children usa Legislature
1) "House"
2) "Senate"


# Get Legislature Descendants(BFS)
127.0.0.1:6379>  tree.get_descendants usa  Legislature
1) "Legislature"
2) "House"
3) "Senate"
4) "Pelosi"
5) "Harris"


Run

Linux

redis-server --loadmodule yourpath/libretree.so

Mac

redis-server --loadmodule ./target/debug/libretree.dylib

Config

loadmodule /yourpath/libretree.so

Dev

Prerequisites

Makefile

build                          build retree docker image
builder                        build rust cross-compiler base image, for mac developers
clean                          clean
push                           push to pornhub
test                           do some behavioral tester
tester                         build tester image

TODO

  • Postgres ltree gist index
  • Postgres ltree query
  • Hash Index

Thanks

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].