定制 blomstra/flarum-redis 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

blomstra/flarum-redis

最新稳定版本:0.4.2

Composer 安装命令:

composer require blomstra/flarum-redis

包简介

Adds Redis cache, sessions and queue to Flarum

README 文档

README

This library allows using Redis as cache, session and for the queue. You can only enable these services by using a local extender (the extend.php in the root of your Flarum installation). See the "Set up" section below.

This is an advanced utility for webmasters!

Installation

Install manually with composer:

composer require blomstra/flarum-redis:*

Set up

In your extend.php:

return [
    new Blomstra\Redis\Extend\Redis([
        'host' => '127.0.0.1',
        'password' => null,
        'port' => 6379,
        'database' => 1
    ])
];

This enables sessions, cache and queue to run on redis.

See "Use different database for each service" below to split up the database for cache vs sessions, queue because a cache clear action will clear sessions and queue jobs as well if they share the same database.

Advanced configuration

  1. Disable specific services:
return [
    (new Blomstra\Redis\Extend\Redis([
        'host' => '127.0.0.1',
        'password' => null,
        'port' => 6379,
        'database' => 1,
    ]))->disable(['cache', 'queue'])
];
  1. Use different database for each service:
return [
    (new Blomstra\Redis\Extend\Redis([
        'host' => '127.0.0.1',
        'password' => null,
        'port' => 6379,
        'database' => 1,
    ]))
    ->useDatabaseWith('cache', 1)
    ->useDatabaseWith('queue', 2)
    ->useDatabaseWith('session', 3)
];
  1. Completely separate the config array:
return [
    (new Blomstra\Redis\Extend\Redis([
        'connections' => [
            'cache' => [
              'host' => 'cache.int.yoursite.com',
              'password' => 'foo-bar',
              'port' => 6379,
              'database' => 1,
            ],
            'queue' => [
              'host' => 'queue.int.yoursite.com',
              'password' => 'foo-bar',
              'port' => 6379,
              'database' => 1,
            ],
            'session' => [
              'host' => 'session.int.yoursite.com',
              'password' => 'foo-bar',
              'port' => 6379,
              'database' => 1,
            ],
        ],
    ]))
];
  1. Use a cluster:
return [
    (new Blomstra\Redis\Extend\Redis([
        'host' => '127.0.0.1',
        'password' => null,
        'port' => 6379,
        'database' => 1,
        'options' => [
          'replication' => 'sentinel',
          'service' => 'mymaster:26379',
        ]
    ]))
    ->useDatabaseWith('cache', 1)
    ->useDatabaseWith('queue', 2)
    ->useDatabaseWith('session', 3)
];

Queue

Make sure to start your queue workers, see the laravel documentation for specifics. To test the worker can start use php flarum queue:work.

Queue options

The queue allows for several options to be added, retry_after, block_for and after_commit. You can set these by adding a queue array in the configuration:

return [
    (new Blomstra\Redis\Extend\Redis([
        'host' => '127.0.0.1',
        'password' => null,
        'port' => 6379,
        'database' => 1,
        'queue' => [
            'retry_after' => 120, // seconds
            'block_for' => 5, // seconds
            'after_commit' => true 
        ]       
    ]))
    ->useDatabaseWith('cache', 1)
    ->useDatabaseWith('queue', 2)
    ->useDatabaseWith('session', 3)
];

You can read up on the meaning of these options in the Laravel Documentation.

Updating

composer update blomstra/flarum-redis

FAQ

Why are there still files in storage/cache? Some code still relies on physical files being present. This includes the formatter cache and the view caches.

Links

统计信息

  • 总下载量: 43.74k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 15
  • 点击次数: 1
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 15
  • Watchers: 4
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-29