【问题标题】:Eloquent model for RedisRedis 的 Eloquent 模型
【发布时间】:2016-01-17 18:59:38
【问题描述】:

我已经安装了带有 Redis 的 Laravel 5.1,当我测试它时,我收到了错误 Database [redis] not configured.。 比我使用 Redis 而不是 Eloquent 模型从路由测试它:

Route::get('/', function () {
    Redis::set("key", "testValue");
    return Redis::get("key");
});

成功了……

在此之后,我已经搜索并建立了它 - Laravel Redis configuration

那里不支持 Redis

如果我想使用 Redis 怎么办?

【问题讨论】:

    标签: php laravel redis laravel-5


    【解决方案1】:

    有对 Laravel 的 redis 支持

    首先你应该install redis server 并将其作为服务启动。

    config/database.php

    'redis' => [
    
        'cluster' => false,
    
        'default' => [
            'host'     => '127.0.0.1',
            'port'     => 6379,
            'database' => 0,
        ],
    
    ],
    

    用法示例:

    \Cache::store('redis')->get('key', 'value', 10);
    \Cache::store('redis')->get('key');
    

    官方文档: https://laravel.com/docs/5.1/redis

    【讨论】:

      猜你喜欢
      • 2016-09-04
      • 2015-10-28
      • 2019-09-20
      • 2014-02-05
      • 2015-08-05
      • 2015-03-12
      • 2015-08-10
      • 2014-11-22
      • 2014-06-07
      相关资源
      最近更新 更多