PHPackages                             frcstc/luatree - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. frcstc/luatree

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

frcstc/luatree
==============

lua and redis tree

v1.0(5y ago)751MITPHPPHP &gt;=7.2

Since Jun 8Pushed 4y ago1 watchersCompare

[ Source](https://github.com/frcstc/deep-tree-compontent)[ Packagist](https://packagist.org/packages/frcstc/luatree)[ RSS](/packages/frcstc-luatree/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

frcstc/luatree 基于hyperf框架 lua+redis实现无限递归查询
===========================================

[](#frcstcluatree---基于hyperf框架-luaredis实现无限递归查询)

```
composer require frcstc/luatree

```

利用 redis + lua实现多层级递归查询
-----------------------

[](#利用-redis---lua实现多层级递归查询)

### 使用方法：

[](#使用方法)

```
$addNode1 = new AddNode([
  'userId' => 'test1', //用户标识
  'inviteUserId' => 'test2',//上级或邀请人标识
  'userLevelId' => 1, //用户等级
  'childrenIds' => [],// 直属下级
]);
$addNode2 = new AddNode([
  'userId' => 'test2',
  'inviteUserId' => 'test3',
  'userLevelId' => 2,
  'childrenIds' => ['test1'],
]);
$addNode3 = new AddNode([
  'userId' => 'test3',
  'inviteUserId' => 'test4',
  'userLevelId' => 3,
  'childrenIds' => ['test2'],
]);

$addNode4 = new AddNode([
  'userId' => 'test4',
  'inviteUserId' => '',
  'userLevelId' => 4,
  'childrenIds' => ['test3'],
]);
//存入缓存
$hashKey = "userTestHash"; //redis hset的 key
$treeUtil = new TreeUtil();
$treeUtil->add($hashKey, $addNode1);
$treeUtil->add($hashKey, $addNode2);
$treeUtil->add($hashKey, $addNode3);
$treeUtil->add($hashKey, $addNode4);

// 获取所有父节点
$treeUtil->getParent($hashKey, 'test1');
// 获取所有子节点
$treeUtil->getChildrenList($hashKey, 'test4');

```

### 此方案 利用了redis hset 以及lua函数尾调用 来消除栈内存 达到理论上无限递归的可能，优点是可以支持较大数据量，缺点是 数据存储格式固定，可以继承treeUtil 进行扩展

[](#此方案-利用了redis-hset-以及lua函数尾调用-来消除栈内存-达到理论上无限递归的可能优点是可以支持较大数据量缺点是-数据存储格式固定可以继承treeutil-进行扩展)

blog:
----------------------------------

[](#bloghttpwwwhzgoodnetblogs)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2163d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4fc24f46a7769e6f48546d551bb6a6270b6aca392a88bbd452653fb5f875fcbb?d=identicon)[fangrencai](/maintainers/fangrencai)

---

Top Contributors

[![frcstc](https://avatars.githubusercontent.com/u/30496778?v=4)](https://github.com/frcstc "frcstc (10 commits)")

---

Tags

phphyperf

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/frcstc-luatree/health.svg)

```
[![Health](https://phpackages.com/badges/frcstc-luatree/health.svg)](https://phpackages.com/packages/frcstc-luatree)
```

###  Alternatives

[hyperf/watcher

Hot reload watcher for Hyperf

17846.7k27](/packages/hyperf-watcher)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
