PHPackages                             alan/swoft-cache-proxy - 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. alan/swoft-cache-proxy

ActiveLibrary[Caching](/categories/caching)

alan/swoft-cache-proxy
======================

swoft framework cache aop proxy

v1.0.0(6y ago)27PHPPHP &gt;=7.1CI failing

Since Mar 4Pushed 6y ago1 watchersCompare

[ Source](https://github.com/wzzjjboy/swoft-cache-proxy)[ Packagist](https://packagist.org/packages/alan/swoft-cache-proxy)[ RSS](/packages/alan-swoft-cache-proxy/feed)WikiDiscussions master Synced yesterday

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

swoft-cache-proxy
=================

[](#swoft-cache-proxy)

1. #### 特性

    [](#特性)

    - 基于框架本身AOP和Annotation实现
    - 接入成本较低
2. #### 安装

    [](#安装)

    composer require alan/swoft-cache-proxy
3. #### 配置redis

    [](#配置redis)

    ```
    'redis'               => [
        'class'         => RedisDb::class,
        'host'          => env("REDIS_HOST"),
        'port'          => env("REDIS_PORT"),
        'database'      => env("REDIS_DATABASE"),
        'retryInterval' => 10,
        'readTimeout'   => 0,
        'timeout'       => 2,
        'password'      => env("REDIS_PASSWORD"),
        'driver'        => 'phpredis',
        'option'        => [
            'prefix' => 'swoft_app_name',
            'serializer' => Redis::SERIALIZER_NONE,
        ],
    ],
    'redis.pool'          => [
        'class'       => \Swoft\Redis\Pool::class,
        'redisDb'     => \bean('redis'),
        'minActive'   => 10,
        'maxActive'   => 20,
        'maxWait'     => 0,
        'maxWaitTime' => 0,
        'maxIdleTime' => 60,
    ]
    ```
4. #### 在业务上层代码引入Cache注解

    [](#在业务上层代码引入cache注解)

    ```
    use alan\swoft_cache_proxy\Annotation\Mapping\Cache;
    use  alan\swoft_cache_proxy\Helper\CacheRspHelper;

    /**
     * @Cache(isQuery=true)
     * @return array
     */
    public function testQuery() {
        $cacheFlagValue = 123;
        $now = time(); //业务代码
        return CacheRspHelper::makeRsp(['now' => $now], $cacheFlagValue);
    }

    /**
     * @Cache(isQuery=false)
     * @return array
     */
    public function testUpdate() {
        //... 业务上的更新操作
        $data = []; //业务操作返回
        return CacheRspHelper::makeRsp($data, $cacheFlagValue);
    }
    ```

```

   - 引入Cache注释，注意要引入命令空间
   - Cache注释有个isQuery的属性，如果当前的操作是查询则设置为true,如果当前是更新操作则为false.比如前当我们是从数据库里面查出某个用户的订单，这里会把查询结果缓存起来，如果是更新某个用户订单则会把之前查询的缓存清空。
   - 如果isQuery=ture时，返回数据时需要使用CacheRspHelper::makeRsp函数返回。第一个参数为业务层返回的数据（即需要缓存的数据）、第二个参数为缓存数据的归属者标识字段，如何上面我们查询的是某用户(uid=10000)的订单列表数据，那这里应该传入该用户的uid(即10000).
   - 上层(比如控制器)获取数据时需要调用CacheRspHelper::getRsp函数

```

###  Health Score

24

—

LowBetter than 30% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Unknown

Total

1

Last Release

2357d ago

### Community

Maintainers

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

---

Top Contributors

[![lzcmaro](https://avatars.githubusercontent.com/u/15357931?v=4)](https://github.com/lzcmaro "lzcmaro (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alan-swoft-cache-proxy/health.svg)

```
[![Health](https://phpackages.com/badges/alan-swoft-cache-proxy/health.svg)](https://phpackages.com/packages/alan-swoft-cache-proxy)
```

###  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)[swoft/redis

swoft redis component

12172.1k17](/packages/swoft-redis)[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)
