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

ActiveLibrary[Caching](/categories/caching)

xiaorenaishu/redis.sdk
======================

基于redis的通用功能组件：分布式原子锁，原子计数器，通用缓存基类等

v1.0.0(5y ago)13MITPHP

Since Jul 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/xiaorenaishu/redis.sdk)[ Packagist](https://packagist.org/packages/xiaorenaishu/redis.sdk)[ RSS](/packages/xiaorenaishu-redissdk/feed)WikiDiscussions master Synced today

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

前置说明
----

[](#前置说明)

```
该组件致力于为快速迭代的业务提供统一的redis组件操作方式，降低业务代码的复杂度与冗余度。

```

\##安装组件

```
COMPOSER_MEMORY_LIMIT=-1
composer require xiaorenaishu/redis.sdk:dev-master -vvv
```

使用方式
----

[](#使用方式)

- 分布式锁

```
/**
 * 声明自定义锁
 */
use RedisComponent\Operator\Locker;

class XxxLocker extends Locker
{
    protected $connection = 'default';
    protected $preFix = CacheConst::PREFIX;
    protected $inFix = CacheConst::INFIX;
    protected $ttl = CacheConst::SEC;
}

/**
 * 锁使用
 */
/** @var XxxLocker $locker */
$locker = app(XxxLocker::class);
try {
    $locker->setKey(key)->setTtl(10)->setUniq(uniqid)->lock();
} catch (Exception $e) {

} finally {
    $locker->unlock();
}
```

- 计数器

```
/**
 * 声明计数器
 */
use RedisComponent\Operator\Counter;

class XxxCounter extends Counter
{
    protected $connection = 'default';
    protected $preFix = CacheConst::PREFIX;
    protected $inFix = CacheConst::INFIX;
    protected $ttl = CacheConst::SEC;
}

/**
 * 执行计数
 */
/** @var XxxCounter $counter */
$counter = app(XxxCounter::class);
$num = $counter->setKey(id)->incr(1);

/**
 * 针对需要不同ttl的计数场景可动态配置
 */
$num = $counter->setKey(id)->setTtl(3600)->incr(1);
```

- 通用缓存基类

```
/**
 * 声明自定义锁
 */
use RedisComponent\Operator\Cache;

class XxxCache extends Cache
{
    protected $connection = 'default';
    protected $preFix = CacheConst::PREFIX;
    protected $inFix = CacheConst::INFIX;
    protected $ttl = CacheConst::SEC;
}

/** @var XxxCache $cache */
$cache = app(XxxCache::class);

/**
 * 单key读写缓存
 */
$cache->setKey(key)->set(val);
$cache->setKey(key)->get();

/**
 * 多key读写缓存
 */
$cache->mset(keyValueMap);
$cache->mget(keys);

//todo 更多通用操作
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

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

Total

2

Last Release

2062d ago

Major Versions

v0.0.1 → v1.0.02020-09-15

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/21195871?v=4)[xiaorenaishu](/maintainers/xiaorenaishu)[@xiaorenaishu](https://github.com/xiaorenaishu)

### Embed Badge

![Health badge](/badges/xiaorenaishu-redissdk/health.svg)

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

###  Alternatives

[monospice/laravel-redis-sentinel-drivers

Redis Sentinel integration for Laravel and Lumen.

103830.5k](/packages/monospice-laravel-redis-sentinel-drivers)[namoshek/laravel-redis-sentinel

An extension of Laravels Redis driver which supports connecting to a Redis master through Redis Sentinel.

38679.0k](/packages/namoshek-laravel-redis-sentinel)[yangusik/laravel-balanced-queue

Laravel queue management with load balancing between partitions (user groups)

786.4k](/packages/yangusik-laravel-balanced-queue)[vetruvet/laravel-phpredis

Use phpredis as the redis connection in Laravel

43123.7k](/packages/vetruvet-laravel-phpredis)[ginnerpeace/laravel-redis-lock

Simple redis distributed locks for Laravel.

15114.4k](/packages/ginnerpeace-laravel-redis-lock)[huangdijia/laravel-redis-ide-helper

Redis ide-helper for Laravel.

1243.3k](/packages/huangdijia-laravel-redis-ide-helper)

PHPackages © 2026

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