PHPackages                             vivlong/phalapi-redis2 - 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. [Caching](/categories/caching)
4. /
5. vivlong/phalapi-redis2

Abandoned → [vivlong/phalapi-xredis](/?search=vivlong%2Fphalapi-xredis)Library[Caching](/categories/caching)

vivlong/phalapi-redis2
======================

PhalApi 2.x 扩展类库 - Redis 丰富基础redisCache类功能,更贴切复杂场景下的redis使用。

2.0.0(8y ago)013GPL-3.0-or-laterPHPPHP &gt;=5.3.3

Since Jan 25Pushed 5y agoCompare

[ Source](https://github.com/vivlong/phalapi-redis2)[ Packagist](https://packagist.org/packages/vivlong/phalapi-redis2)[ Docs](https://www.phalapi.net/)[ RSS](/packages/vivlong-phalapi-redis2/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

PhalApi 2.x 的Redis扩展
====================

[](#phalapi-2x-的redis扩展)

PhalApi 2.x扩展类库，从 Redis 2.6.12 版本开始， SET 命令的行为可以通过一系列参数来修改，并集成了简单的Redis分布式锁

安装和配置
-----

[](#安装和配置)

修改项目下的composer.json文件，并添加：

```
    "vivlong/phalapi-xredis":"dev-master"

```

然后执行`composer update`。

安装成功后，添加以下配置到/path/to/phalapi/config/app.php文件：

```
    /**
     * 扩展类库 - Redis扩展
     */
    'Xredis' => array(
        //Redis链接配置项
        'servers'  => array(
            'host'   => '127.0.0.1',        //Redis服务器地址
            'port'   => '6379',             //Redis端口号
            'prefix' => 'PhalApi_',         //Redis-key前缀
            'auth'   => 'phalapi',          //Redis链接密码
        ),
        // Redis分库对应关系操作时直接使用名称无需使用数字来切换Redis库
        'DB'       => array(
            'developers' => 1,
            'user'       => 2,
            'code'       => 3,
        ),
        //使用阻塞式读取队列时的等待时间单位/秒
        'blocking' => 5,
    ),
```

并根据自己的情况修改填充。

注册
--

[](#注册)

在/path/to/phalapi/config/di.php文件中，注册：

```
$di->cache = function () {
    return new \PhalApi\Xredis\Lite(\PhalApi\DI()->config->get("app.Xredis.servers"));
};
```

使用
--

[](#使用)

常用基础操作(具体API可以查阅代码中src/Lite.php)

```
// 存入永久的键值队
\PhalApi\DI()->redis->set_forever(键名,值,库名);
// 获取永久的键值队
\PhalApi\DI()->redis->get_forever(键名, 库名);

// 存入一个有时效性的键值队,默认600秒
\PhalApi\DI()->redis->set_Time(键名,值,有效时间,库名);
// 获取一个有时效性的键值队
\PhalApi\DI()->redis->get_Time(键名, 库名);

// 写入队列左边
\PhalApi\DI()->redis->set_Lpush(队列键名,值, 库名);
// 读取队列右边
\PhalApi\DI()->redis->get_lpop(队列键名, 库名);
// 读取队列右边 如果没有读取到阻塞一定时间(阻塞时间或读取配置文件blocking的值)
\PhalApi\DI()->redis->get_Brpop(队列键名,值, 库名);

// 删除一个键值队适用于所有
\PhalApi\DI()->redis->del(键名, 库名);
// 自动增长
\PhalApi\DI()->redis->get_incr(键名, 库名);
// 切换DB并且获得操作实例
\PhalApi\DI()->redis->get_redis(键名, 库名);

```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 56.3% 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

3032d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/63cebb214330833e8bea309160266105934daf5e70e20db7ae58a6484443f37c?d=identicon)[vivlong](/maintainers/vivlong)

---

Top Contributors

[![wenzhenxi](https://avatars.githubusercontent.com/u/12265719?v=4)](https://github.com/wenzhenxi "wenzhenxi (9 commits)")[![vivlong](https://avatars.githubusercontent.com/u/3961154?v=4)](https://github.com/vivlong "vivlong (7 commits)")

---

Tags

redisphalapiphalapi-redis

### Embed Badge

![Health badge](/badges/vivlong-phalapi-redis2/health.svg)

```
[![Health](https://phpackages.com/badges/vivlong-phalapi-redis2/health.svg)](https://phpackages.com/packages/vivlong-phalapi-redis2)
```

###  Alternatives

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[clue/redis-protocol

A streaming Redis protocol (RESP) parser and serializer written in pure PHP.

5311.0M13](/packages/clue-redis-protocol)[cache/redis-adapter

A PSR-6 cache implementation using Redis (PhpRedis). This implementation supports tags

523.9M27](/packages/cache-redis-adapter)[phalapi/redis

PhalApi 2.x 扩展类库 - Redis 丰富基础redisCache类功能,更贴切复杂场景下的redis使用。

122.6k](/packages/phalapi-redis)[rtcamp/nginx-helper

Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also provides cloudflare edge cache purging with Cache-Tags.

23817.0k1](/packages/rtcamp-nginx-helper)

PHPackages © 2026

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