mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-26 22:40:45 +00:00
Update InstanceService, define cache keys
This commit is contained in:
parent
e925287824
commit
72918a4b09
2 changed files with 11 additions and 6 deletions
|
@ -7,6 +7,7 @@ use App\{Instance, Profile};
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
use App\Services\InstanceService;
|
||||||
|
|
||||||
trait AdminInstanceController
|
trait AdminInstanceController
|
||||||
{
|
{
|
||||||
|
@ -126,9 +127,9 @@ trait AdminInstanceController
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cache::forget('instances:banned:domains');
|
Cache::forget(InstanceService::CACHE_KEY_BANNED_DOMAINS);
|
||||||
Cache::forget('instances:unlisted:domains');
|
Cache::forget(InstanceService::CACHE_KEY_UNLISTED_DOMAINS);
|
||||||
Cache::forget('instances:auto_cw:domains');
|
Cache::forget(InstanceService::CACHE_KEY_NSFW_DOMAINS);
|
||||||
|
|
||||||
return response()->json([]);
|
return response()->json([]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,10 @@ use App\Instance;
|
||||||
|
|
||||||
class InstanceService
|
class InstanceService
|
||||||
{
|
{
|
||||||
|
const CACHE_KEY_BANNED_DOMAINS = 'instances:banned:domains';
|
||||||
|
const CACHE_KEY_UNLISTED_DOMAINS = 'instances:unlisted:domains';
|
||||||
|
const CACHE_KEY_NSFW_DOMAINS = 'instances:auto_cw:domains';
|
||||||
|
|
||||||
public static function getByDomain($domain)
|
public static function getByDomain($domain)
|
||||||
{
|
{
|
||||||
return Cache::remember('pf:services:instance:by_domain:'.$domain, 3600, function() use($domain) {
|
return Cache::remember('pf:services:instance:by_domain:'.$domain, 3600, function() use($domain) {
|
||||||
|
@ -16,21 +20,21 @@ class InstanceService
|
||||||
|
|
||||||
public static function getBannedDomains()
|
public static function getBannedDomains()
|
||||||
{
|
{
|
||||||
return Cache::remember('instances:banned:domains', now()->addHours(12), function() {
|
return Cache::remember(self::CACHE_KEY_BANNED_DOMAINS, now()->addHours(12), function() {
|
||||||
return Instance::whereBanned(true)->pluck('domain')->toArray();
|
return Instance::whereBanned(true)->pluck('domain')->toArray();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUnlistedDomains()
|
public static function getUnlistedDomains()
|
||||||
{
|
{
|
||||||
return Cache::remember('instances:unlisted:domains', now()->addHours(12), function() {
|
return Cache::remember(self::CACHE_KEY_UNLISTED_DOMAINS, now()->addHours(12), function() {
|
||||||
return Instance::whereUnlisted(true)->pluck('domain')->toArray();
|
return Instance::whereUnlisted(true)->pluck('domain')->toArray();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getNsfwDomains()
|
public static function getNsfwDomains()
|
||||||
{
|
{
|
||||||
return Cache::remember('instances:auto_cw:domains', now()->addHours(12), function() {
|
return Cache::remember(self::CACHE_KEY_NSFW_DOMAINS, now()->addHours(12), function() {
|
||||||
return Instance::whereAutoCw(true)->pluck('domain')->toArray();
|
return Instance::whereAutoCw(true)->pluck('domain')->toArray();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue