Skip to content

Commit 153276e

Browse files
committed
Use APCu instead of file-based cache
1 parent c28241b commit 153276e

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

extend.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use App\Console\PurgeSuspendedUsers;
1616
use App\Middleware\ContentSecurityPolicy;
1717
use App\Middleware\NoCacheHeader;
18+
use App\ServiceProvider\ApcuCacheProvider;
1819
use App\ServiceProvider\ErrorLogProvider;
1920
use App\ServiceProvider\SessionServiceProvider;
2021
use Flarum\Extend;
@@ -41,6 +42,7 @@
4142
(new Extend\Console())
4243
->command(PurgeSuspendedUsers::class)
4344
->schedule(PurgeSuspendedUsers::class, fn (Event $event) => $event->daily()),
45+
(new Extend\ServiceProvider())->register(ApcuCacheProvider::class),
4446
(new Extend\ServiceProvider())->register(ErrorLogProvider::class),
4547
(new Extend\ServiceProvider())->register(SessionServiceProvider::class),
4648
(new Extend\Middleware('forum'))->add(ContentSecurityPolicy::class),
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace App\ServiceProvider;
4+
5+
use Flarum\Foundation\AbstractServiceProvider;
6+
use Illuminate\Cache\ApcStore;
7+
use Illuminate\Cache\ApcWrapper;
8+
use Illuminate\Contracts\Cache\Store;
9+
10+
class ApcuCacheProvider extends AbstractServiceProvider
11+
{
12+
public function register(): void
13+
{
14+
$this->container->singleton('cache.filestore', fn (): ApcStore => new ApcStore(new ApcWrapper(), 'flarum_'));
15+
$this->container->alias('cache.filestore', Store::class);
16+
}
17+
}

0 commit comments

Comments
 (0)