jmiy/hyperf-i-cache-3-2

Illuminate Cache for Hyperf
36
Install
composer require jmiy/hyperf-i-cache-3-2
PHP:>=8.0
License:MIT
Last Updated:Aug 18, 2026
Links: GitHub  ·  Packagist
Maintainer: Jmiy

Laravel 缓存系统

illuminate/cache

安装

composer require jmiy/hyperf-i-cache-3-2

配置

创建配置文件

php bin/hyperf.php vendor:publish jmiy/hyperf-i-cache-3-2

配置如下

因为其他缓存驱动暂时无法被协程化,所以只支持 array file 和 redis

<?php

declare(strict_types=1);

use function Hyperf\Support\env;
use Hyperf\Stringable\Str;

return [
    /*
    |--------------------------------------------------------------------------
    | Default Cache Store
    |--------------------------------------------------------------------------
    |
    | This option controls the default cache connection that gets used while
    | using this caching library. This connection is used when another is
    | not explicitly specified when executing a given caching function.
    |
    */

    'default' => env('CACHE_DRIVER', 'array'),

    /*
    |--------------------------------------------------------------------------
    | Cache Stores
    |--------------------------------------------------------------------------
    |
    | Here you may define all of the cache "stores" for your application as
    | well as their drivers. You may even define multiple stores for the
    | same cache driver to group types of items stored in your caches.
    |
    | Supported drivers: "apc", "array", "database", "file",
    |            "memcached", "redis", "dynamodb", "null"
    |
    */

    'stores' => [
        'array' => [
            'driver' => 'array',
            'serialize' => false,
        ],

        'file' => [
            'driver' => 'file',
            'path' => BASE_PATH . '/storage/cache/data',
        ],

        'redis' => [
            'driver' => 'redis',
            'connection' => 'default',
            'lock_connection' => 'default',
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Cache Key Prefix
    |--------------------------------------------------------------------------
    |
    | When utilizing a RAM based store such as APC or Memcached, there might
    | be other applications utilizing the same cache. So, we'll specify a
    | value to get prefixed to all our keys so we can avoid collisions.
    |
    */

    'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache'),
];

使用

文档地址 https://learnku.com/docs/laravel/8.x/cache/9389

助手函数

本组件实现了与 Laravel 一模一样的助手函数,但增加了命名空间,故使用时,可以按照以下方式

<?php
use function Illuminate\Cache\cache;

cache()->put('xxx', 'yyy');

Related Packages

cooper/hyperf-pest

Pest Testing for hyperf

29 2
limingxinleo/i-encryption

Illuminate Encryption for Hyperf

622 6
hyperf/tappable

Hyperf Macroable package which come from illuminate/tappable

1,467,140 1
hyperf/conditionable

Hyperf Macroable package which come from illuminate/conditionable

1,457,803 0
hyperf/scout

Hyperf Scout provides a driver based solution to searching your Eloquent models....

182,967 6