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(1y ago)0151MITPHPPHP &gt;=7.0

Since Jan 11Pushed 1y ago1 watchersCompare

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

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

30

—

LowBetter than 61% of packages

Maintenance43

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community7

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

Every ~244 days

Recently: every ~302 days

Total

6

Last Release

455d 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

[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21114.2k](/packages/iazaran-smart-cache)[phpfastcache/phpssdb

PHP SSDB Driver for phpFastCache

14736.9k1](/packages/phpfastcache-phpssdb)[rapidwebltd/rw-file-cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

15196.8k7](/packages/rapidwebltd-rw-file-cache)[yuzuru-s/redis-recommend

Wrapping Redis's sorted set APIs for specializing recommending operations.

392.9k](/packages/yuzuru-s-redis-recommend)[ichhabrecht/intcache

Turn uncachable page objects into cacheable links

193.9k](/packages/ichhabrecht-intcache)

PHPackages © 2026

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