Skip to content
Joe Huss edited this page Nov 10, 2022 · 1 revision

Cache

在webmannative templates symfony/cacheascacheComponent。

The redis extension must be installed for php-cli before using symfony/cache

Install

php 7.x

composer require psr/container ^1.1.1 illuminate/redis ^8.2.0 symfony/cache ^5.2

php 8.x

composer require psr/container ^1.1.1 illuminate/redis symfony/cache

RedisConfigure

redisConfiguration file inconfig/redis.php

return [
    'default' => [
        'host'     => '127.0.0.1',
        'password' => null,
        'port'     => 6379,
        'database' => 0,
    ]
];

Examples

<?php
namespace app\controller;

use support\Request;
use support\Cache;

class UserController
{
    public function db(Request $request)
    {
        $key = 'test_key';
        Cache::set($key, rand());
        return response(Cache::get($key));
    }
}

Note keyTry to add a prefix to avoid conflicts with other businesses that use redis

Using other Cache components

ThinkCachee.g. statistics about a Define routes in

Clone this wiki locally