小编mel*_*rte的帖子

Symfony 3:使用Redis配置缓存组件池

我想使用新的缓存组件在Redis中存储数据。

我想为池配置不同的数据生存期。

现在,我配置了:

framework:
    cache:
        app: cache.adapter.redis
        default_redis_provider: "redis://localhost:6379"
        pools:
            app.cache.codification:
                adapter: cache.app
                default_lifetime: 86400
            app.cache.another_pool:
                adapter: cache.app
                default_lifetime: 600
Run Code Online (Sandbox Code Playgroud)

但是我不知道如何app.cache.codification在我的代码中使用池。我宣布了以下服务:

acme.cache.repository.code_list:
    class: Acme\Cache\Repository\CodeList
    public: false
    arguments:
        - "@cache.app"
        - "@acme.webservice.repository.code_list"
Run Code Online (Sandbox Code Playgroud)

我这样使用它:

class CodeList
{
    private $webserviceCodeList;

    /**
     * @var AbstractAdapter
     */
    private $cacheAdapter;

    public static $CACHE_KEY = 'webservices.codification.search';

    private $lists;

    /**
     * @param AbstractAdapter $cacheAdapter
     * @param WebserviceCodeList $webserviceCodeList
     */
    public function __construct($cacheAdapter, $webserviceCodeList)
    {
        $this->cacheAdapter = $cacheAdapter;
        $this->webserviceCodeList = $webserviceCodeList;
    }

    /**
     * @param …
Run Code Online (Sandbox Code Playgroud)

redis symfony symfony-3.2

7
推荐指数
1
解决办法
3632
查看次数

如何在 Laravel 中显示警告和弃用消息

如果我编写一些带有弃用通知的 PHP 代码,它会显示在本地环境中。

示例:index.php

<?php

function super(string $test='', string $essai)
{
    return 'toto';
}

super('sy', 1);

exit;
Run Code Online (Sandbox Code Playgroud)

显示:

Deprecated: Optional parameter $test declared before required parameter $essai is implicitly treated as a required parameter in /var/www/public/index.php on line 9
Run Code Online (Sandbox Code Playgroud)

这很好。

但是 Laravel 控制器中的完全相同的代码不会显示,并且不会存储在任何日志文件中。我将配置 app.env 设置为“local”,将 app.debug 设置为 true,将 app.log_level 设置为“debug”。知道我缺少什么吗?

debugging logging laravel laravel-blade log-level

3
推荐指数
1
解决办法
3170
查看次数

Laravel:使用带有偏移和限制的惰性似乎不起作用

我正在尝试将模型进程的一些处理拆分为多个作业。假设我要处理 300 个模型。我想启动3个作业,每个作业将处理100个模型。在每项工作中,我想按 10 个模型为一组进行延迟加载。

如果我执行以下代码:

$models = MyModel::offset(0)->limit(100)->lazy(10);
$j = 0;

foreach ($models as $model) {
  $j++;
}
echo $j;
Run Code Online (Sandbox Code Playgroud)

输出是: 300 我认为只应该处理 100 个模型。

我不明白为什么我的所有模型都被处理。

如果有人知道真相...:)

laravel eloquent

2
推荐指数
1
解决办法
913
查看次数