1
0
Fork 0
forked from mirror/pixelfed
pixelfed/app/Services/BookmarkService.php

32 lines
657 B
PHP
Raw Normal View History

2022-01-27 12:17:55 +00:00
<?php
namespace App\Services;
use App\Bookmark;
use Illuminate\Support\Facades\Cache;
2022-01-29 01:27:53 +00:00
use Illuminate\Support\Facades\Redis;
2022-01-27 12:17:55 +00:00
class BookmarkService
{
2022-01-29 01:27:53 +00:00
const CACHE_KEY = 'pf:services:bookmarks:';
2022-01-27 12:17:55 +00:00
public static function get($profileId, $statusId)
{
2022-01-29 01:27:53 +00:00
if (!Redis::zcard(self::CACHE_KEY . $profileId)) {
return false;
}
return Redis::zscore(self::CACHE_KEY . $profileId, $statusId) != null;
}
public static function add($profileId, $statusId)
{
return Redis::zadd(self::CACHE_KEY . $profileId, $statusId, $statusId);
}
public static function del($profileId, $statusId)
{
return Redis::zrem(self::CACHE_KEY . $profileId, $statusId);
2022-01-27 12:17:55 +00:00
}
}