PHPackages                             fuyelk/redis - 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. fuyelk/redis

ActiveLibrary[Caching](/categories/caching)

fuyelk/redis
============

Redis的常用操作的封装

1.2.2(11mo ago)0149MITPHPPHP &gt;=7.0

Since Jan 11Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/fuyelk/redis)[ Packagist](https://packagist.org/packages/fuyelk/redis)[ RSS](/packages/fuyelk-redis/feed)WikiDiscussions main Synced 4d ago

READMEChangelogDependenciesVersions (7)Used By (0)

Redis常用方法封装
-----------

[](#redis常用方法封装)

安装
--

[](#安装)

> composer require fuyelk/redis

特性
--

[](#特性)

1. 自动为每个项目创建独立的键名前缀，解决了同一台服务器上Redis数据混淆的问题
2. 自动将非标量数据转换为序列化的字符串来存储，并在读取时自动解析
3. 自动断线重连
4. 相较于PHP原生库，增加了以下几个方法：
    - 简单高效的锁：`lock/unlock`
    - 通过集合删除数据：`delBySet`
    - 删除全部数据：`delAll`
    - 获取全部数据名：`keys`
    - 获取全部数据：`allData`

### 方法

[](#方法)

```
    $redis = new \fuyelk\redis\Redis();

    // 创建记录
    $redis->set('name', 'zhangsan'));

    // 读取记录
    $redis->get('name', 'default'));

    // 数据不存在则创建
    $redis->setnx('exist', 'yes'));

    // 删除记录
    $redis->del('age'));

    // 通过集合删除缓存
    $redis->delBySet('users'));

    // 删除全部数据
    $redis->delAll());

    // 数值自增
    $redis->inc('money', 5));

    // 记录自减
    $redis->dec('money', 5));

    // 符合当前前缀全部键名
    $redis->keys());

    // Redis缓存中的全部键名
    $redis->keys(true));

    // 符合当前前缀的所有数据
    $redis->allData());

    // redis缓存中的所有数据
    $redis->allData(true));

    // 锁foo 10秒
    $redis->lock('foo', 10));

    // 解锁foo
    $redis->unlock('foo'));
    ...

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance50

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

Every ~244 days

Recently: every ~302 days

Total

6

Last Release

358d ago

Major Versions

0.1.3 → 1.02022-02-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/3e8b65807d7c8e5146394e3b72dbb22f7002688b5d7310557595ca201c0da686?d=identicon)[fuyelk](/maintainers/fuyelk)

---

Top Contributors

[![fuyelk](https://avatars.githubusercontent.com/u/18348153?v=4)](https://github.com/fuyelk "fuyelk (19 commits)")

### Embed Badge

![Health badge](/badges/fuyelk-redis/health.svg)

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

###  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)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)

PHPackages © 2026

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