gpt4 book ai didi

How to disable caching for laravel pennant in db(如何在数据库中禁用LARAVEL三角旗的缓存)

转载 作者:bug小助手 更新时间:2023-10-24 17:54:50 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 pennant作为功能标志,本质上只是在功能启用或未启用时才读取。有没有办法让Pennant不使用数据库而将数据存储在Feature表中?我希望对每个请求计算功能标志。


更多回答
优秀答案推荐

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雄辩查询的缓存,可以使用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文件中将PENANT_STORE设置为ARRAY以使用内存存储。


PENNANT_STORE=array

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

要使更改生效,您可能需要运行php artisan Optimize。


更多回答

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