PHP code example of webman-tech / laravel-cache

1. Go to this page and download the library: Download webman-tech/laravel-cache library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

webman-tech / laravel-cache example snippets


return [
    'extend' => function(\Illuminate\Cache\CacheManager $cache) {
        $cache->extend('mongo', function () use ($cache) {
           return $cache->repository(new MongoStore);
        });
    }
];

// PSR-16 简单缓存
$psr16 = Cache::psr16();

// PSR-6 缓存池(需要安装 symfony/cache)
$psr6 = Cache::psr6();

use Webman\Route;
use WebmanTech\LaravelCache\Middleware\ThrottleRequestsFactory;

Route::get('/api/users', [UserController::class, 'index'])
    ->middleware([
        new ThrottleRequestsFactory([
            'limiter_for' => 'api', // 需要在 rate_limiter.php 中配置
        ]),
    ]);