gpt4 book ai didi

How to disable caching for laravel pennant in db(如何禁用数据库中laravel-pennant的缓存)

转载 作者:bug小助手 更新时间:2023-10-22 17:34:21 25 4
gpt4 key购买 nike



I am using laravel pennant for feature flags, essentially only for reading if the features are enabled or not. Is there a way for pennant to not use the DB and store data in Features table? I want the feature flags to be computed on every request.

我使用laravel三角旗作为功能标志,本质上只用于读取功能是否启用。三角旗有没有办法不使用数据库并将数据存储在Features表中?我希望每个请求都能计算出功能标志。


更多回答
优秀答案推荐

If you want to disable caching for Laravel Eloquent queries, you can do so by turning off query caching using the disableQueryLog method. Here's how you can use it:

如果要禁用Laravel-Eloquent查询的缓存,可以使用disableQueryLog方法关闭查询缓存。以下是如何使用它:


DB::connection()->disableQueryLog();

Here it's example:

以下是示例:


public function someControllerMethod()
{
// Disable query caching for this specific method
DB::connection()->disableQueryLog();

// Your Eloquent queries go here
$results = YourModel::where('column', 'value')->get();
}

By calling DB::connection()->disableQueryLog(), you ensure that query caching is disabled for the specific block of code where you need it. This allows you to run queries without caching within that context.

通过调用DB::connection()->disableQueryLog(),您可以确保为您需要的特定代码块禁用查询缓存。这允许您在不缓存该上下文的情况下运行查询。



You can set PENNANT_STORE in your .env file to array to use in-memory storage.

您可以将.env文件中的PENNANT_STORE设置为要在内存存储中使用的数组。


PENNANT_STORE=array

You may need to run php artisan optimize for the change to take effect.

您可能需要运行php-artisan优化才能使更改生效。


更多回答

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com