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

ActiveLibrary[Caching](/categories/caching)

mitirrli/redis-package
======================

Redis periphery applications.

0.0.6(5y ago)0517MITPHP

Since Aug 10Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Mitirrli/redis-package)[ Packagist](https://packagist.org/packages/mitirrli/redis-package)[ RSS](/packages/mitirrli-redis-package/feed)WikiDiscussions master Synced 3w ago

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

 Redis package
===============

[](#-redis-package-)

[![Total Downloads](https://camo.githubusercontent.com/5af7cdcdb0d91b00d060d0e39b49c38b6716b37f66d9e6abb8626808c677d403/68747470733a2f2f706f7365722e707567782e6f72672f6d69746972726c692f72656469732d7061636b6167652f646f776e6c6f616473)](https://packagist.org/packages/mitirrli/redis-package)[![Latest Stable Version](https://camo.githubusercontent.com/134bf709a07d931c1f77a4ed7adea1e1a4179d048c53992385cfcabaabc1a2f9/68747470733a2f2f706f7365722e707567782e6f72672f6d69746972726c692f72656469732d7061636b6167652f762f737461626c65)](https://packagist.org/packages/mitirrli/redis-package)[![Latest Unstable Version](https://camo.githubusercontent.com/36b0f8fdab99d02a08bedf53d2cefe6f430be38664a2c4571ada50f328dce812/68747470733a2f2f706f7365722e707567782e6f72672f6d69746972726c692f72656469732d7061636b6167652f762f756e737461626c65)](https://packagist.org/packages/mitirrli/redis-package)[![License](https://camo.githubusercontent.com/5fb1bcfa6aab3ca4455030706d19a78dfac11497f97c643f8b09ddca062000e0/68747470733a2f2f706f7365722e707567782e6f72672f6d69746972726c692f72656469732d7061636b6167652f6c6963656e7365)](https://packagist.org/packages/mitirrli/redis-package)

A simple redis packages.

Installation
------------

[](#installation)

```
$ composer require "mitirrli/redis-package"
```

> ## Redis Distributed lock
>
> [](#redis-distributed-lock)
>
> 业务逻辑加锁，防止同时操作同一数据

#### App::setRedis()

[](#appsetredis)

若不使用默认配置，可以注入redis对象，返回App对象本身。

```
$redis = new \Redis();
$redis->connect('redis-template.cc');

$app = App::setRedis($redis);

```

#### App::Lock()

[](#applock)

获取Lock对象，同时传入配置项(设置锁的名字，默认加锁时间为10分钟，key为必传项)

```
$Lock = $app::Lock(['key' => 'demo1']);

```

设置加锁时间为1000秒。

```
$Lock = $app::Lock(['key' => 'demo2', 'time' => 1000]);

```

#### lock()

[](#lock)

进行加锁操作，加锁结果以布尔值返回。

```
$Lock->lock()

```

#### unLock()

[](#unlock)

进行解锁操作，解锁结果以布尔值返回。

```
$Lock->unLock()

```

> ## Redis Fixed Array
>
> [](#redis-fixed-array)
>
> 固定大小的数组，元素塞满后，会pop之前的元素，可用于轮播数据等。

#### App::FixedArray()

[](#appfixedarray)

获取FixedArray对象，同时传入配置项(设置key的名字，key为必传项)

```
$FixedArray = $app::FixedArray(['key' => 'demo1']);

```

设置元素数目20个。

```
$FixedArray = $app::FixedArray(['key' => 'demo2', 'len' => 20]);

```

#### toList()

[](#tolist)

往数组中加入数据，最后返回数组元素的数目。

```
$FixedArray->toList('test data');

```

#### lLen()

[](#llen)

获取数组元素的数目。

```
$FixedArray->lLen();

```

#### getItemByIndex()

[](#getitembyindex)

根据数组索引获取数据，下标从0开始，如果没有对应值会抛出异常。

```
$FixedArray->getItemByIndex(0);

```

> ## Redis Sort Set
>
> [](#redis-sort-set)
>
> 固定大小的有序集合。

#### App::FixedSortSet()

[](#appfixedsortset)

获取FixedSortSet对象，同时传入配置项(设置key的名字，key为必传项)

```
$FixedSortSet = $app::FixedSortSet((['key' => 'demo1']);

```

设置集合数目20个。

```
$FixedSortSet = $app::FixedSortSet(['key' => 'demo2', 'len' => 20]);

```

#### toList()

[](#tolist-1)

往集合中加入数据。

```
$FixedSortSet->toList('test data');

```

#### getByIndex()

[](#getbyindex)

获取指定下标的数据(数据由大到小)。

```
$FixedSortSet->getByIndex(0);

```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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 ~56 days

Total

5

Last Release

1927d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ae6fcc430a0d8c57a965a23d47096d0fb28660a2e958c3f9f45f27e7f444a535?d=identicon)[Mitirrli](/maintainers/Mitirrli)

---

Top Contributors

[![Mitirrli](https://avatars.githubusercontent.com/u/50682346?v=4)](https://github.com/Mitirrli "Mitirrli (34 commits)")

### Embed Badge

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

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

###  Alternatives

[pestphp/pest

The elegant PHP Testing Framework.

11.6k72.2M20.6k](/packages/pestphp-pest)[brianium/paratest

Parallel testing for PHP

2.5k136.1M986](/packages/brianium-paratest)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2022.6M343](/packages/drupal-core-dev)

PHPackages © 2026

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