1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-29 11:15:09 +00:00
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
}
}