国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

webman 怎么使用laravel cache?

wanbao520

移植了/congfig/cache.php ;
use Illuminate\Support\Facades\Cache ;

測(cè)試后提示:
RuntimeException: A facade root has not been set. in F:\webman\vendor\illuminate\support\Facades\Facade.php:258
Stack trace:
F:\webman\app\controller\Index.php(10): Illuminate\Support\Facades\Facade::__callStatic('add', Array)
F:\webman\vendor\workerman\webman-framework\src\App.php(146): app\controller\Index->index(Object(support\Request))
F:\webman\vendor\workerman\workerman\Connection\TcpConnection.php(637): Webman\App->onMessage(Object(Workerman\Connection\TcpConnection), Object(support\Request))
F:\webman\vendor\workerman\workerman\Events\Select.php(293): Workerman\Connection\TcpConnection->baseRead(Resource id #196)
F:\webman\vendor\workerman\workerman\Worker.php(2430): Workerman\Events\Select->loop()
F:\webman\vendor\workerman\workerman\Worker.php(1417): Workerman\Worker->run()
F:\webman\vendor\workerman\workerman\Worker.php(1360): Workerman\Worker::forkWorkersForWindows()
F:\webman\vendor\workerman\workerman\Worker.php(542): Workerman\Worker::forkWorkers()
F:\webman\start.php(156): Workerman\Worker::runAll()
{main}

5543 3 1
3個(gè)回答

wanbao520

主要是想使用文件緩存,這個(gè)功能!

  • 暫無(wú)評(píng)論
nitron

主要使用文件緩存的話(huà),就比較簡(jiǎn)單,我只告訴你簡(jiǎn)單實(shí)現(xiàn)過(guò)程,具體實(shí)際需求自己修改代碼
composer require illuminate/cache
composer require illuminate/filesystem

<?php

namespace support\bootstrap;
use Webman\Bootstrap;
use Illuminate\Cache\FileStore;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Cache\Repository;

class Cache implements Bootstrap
{

    protected static $_instance = [];

    public static function start($worker) {
        $fileStore = new FileStore(new Filesystem(),runtime_path());
        self::$_instance = new Repository($fileStore);
    }

    public static function __callStatic($name, $arguments)
    {
        static::$_instance->{$name}(... $arguments);
    }
}

然后 config/bootstrap.php內(nèi)加入一行

return [
    ......
    support\bootstrap\Cache::class,
]

然后重啟就可以了

  • wanbao520 2021-06-04

    非常非常感謝!

  • nitron 2021-06-04

    雖然原代碼不影響使用,但還是更正一下吧
    嚴(yán)謹(jǐn)一點(diǎn),把上面16行的self::$_instance 改成 static::$_instance

  • yzh52521 2021-06-04

    如何改成 redis 或者其他 緩存呢? 請(qǐng)賜教

  • nitron 2021-06-04

    @7845:下面回復(fù)你了

  • wanbao520 2021-06-04

    @8001:非常感謝

nitron

@yzh52521
還是簡(jiǎn)單寫(xiě)的,請(qǐng)根據(jù)自己的具體業(yè)務(wù)需求修改,沒(méi)有跟laravel一樣封裝多種緩存驅(qū)動(dòng),

composer require illuminate/cache
composer require predis/predis
<?php

namespace support\bootstrap;

use Webman\Bootstrap;
use Illuminate\Container\Container;
use Illuminate\Redis\RedisManager;
use Illuminate\Cache\CacheManager;

class Cache implements Bootstrap
{

    protected static $_instance = [];

    public static function start($worker) {
        $container = new Container;
        $container['config'] = [
            'cache.default' => 'redis',
            'cache.stores.redis' => [
                'driver' => 'redis',
                'connection' => 'default'
            ],
            'cache.prefix' => 'webman',
            'database.redis' => [
                'cluster' => false,
                'default' => [
                    'host' => '127.0.0.1',
                    'port' => 6379,
                    'database' => 0,
                    'password' => null
                ],
            ]
        ];

        $container['redis'] = new RedisManager($container, 'predis', $container['config']['database.redis']);
        $cache = new CacheManager($container);
        static::$_instance = $cache->store();
    }

    public static function __callStatic($name, $arguments)
    {
        static::$_instance->{$name}(... $arguments);
    }
}
  • yzh52521 2021-06-04

    我按你file改的

    $config = config('redis');
    $reidsStore =new RedisStore(new RedisManager('', 'phpredis', $config));
    static::$_instance = new Repository($fileStore);

  • nitron 2021-06-04

    可用就行

  • Chuckle 2021-09-18

    @7845:您好 根據(jù)你這個(gè) 為什么redis寫(xiě)入不了呢

  • li3826373 2022-04-06

    很好用

年代過(guò)于久遠(yuǎn),無(wú)法發(fā)表回答
??