gpt4 book ai didi

php - 在 Windows 中从 Laravel 项目中删除 Redis

转载 作者:可可西里 更新时间:2023-11-01 11:23:19 26 4
gpt4 key购买 nike

如果没有运行 Redis,我的项目将无法启动。如果我在 Laravel 中尝试打开一个没有运行 redis 的页面,我会收到这条消息:

“无法建立连接,因为目标机器主动拒绝它。[tcp://127.0.0.1:6379]”

我试过了1) php artisan 配置:缓存,2) php artisan 清除:缓存,3) Composer 删除 predis/predis4) composer 删除 predis5)删除redis实例6)通过命令行卸载redis

任何帮助将不胜感激!谢谢!

缓存.php

<?php

return [

/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
| Supported: "apc", "array", "database", "file", "memcached", "redis"
|
*/

'default' => env('CACHE_DRIVER', 'file'),

/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
*/

'stores' => [

'apc' => [
'driver' => 'apc',
],

'array' => [
'driver' => 'array',
],

'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
],

'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
],

'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],

'redis' => [
'driver' => 'file',
'connection' => 'default',
],

],

/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing a RAM based store such as APC or Memcached, there might
| be other applications utilizing the same cache. So, we'll specify a
| value to get prefixed to all our keys so we can avoid collisions.
|
*/

'prefix' => env(
'CACHE_PREFIX',
str_slug(env('APP_NAME', 'laravel'), '_').'_cache'
),

];

.环境


APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:duZtCSIh12vDNOdmYW2kmMr9ONILxsH55f46npt5/Kg=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=forum
DB_USERNAME=
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=bc05914be7f1db
MAIL_PASSWORD=0c73506a138d3f
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=

RECAPTCHA_SECRET=

最佳答案

如果您不想安装任何缓存服务,如 RedisMemcached,您可以使用 filedatabase Laravel 上的驱动程序。

要更改缓存驱动程序,您必须将 .env 文件中的 CACHE_DRIVER 变量更改为 file,或者修改 config/cache.php 文件。

默认的 cache.php 配置文件如下所示:

/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
| Supported: "apc", "array", "database", "file",
| "memcached", "redis", "dynamodb"
|
*/
'default' => env('CACHE_DRIVER', 'file'),

env() 函数从第一个参数定义的环境变量中获取数据,然后回退到第二个参数定义的值。因此,如果您的 .env 文件定义了一个 CACHE_DRIVER 变量,它将忽略第二个参数值。

有关详细信息,请参阅 https://laravel.com/docs/5.8/cache

关于php - 在 Windows 中从 Laravel 项目中删除 Redis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57343369/

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