forked from GNUsocial/gnu-social
[MEDIA][CACHE] Cache avatar queries and delete stale values; small refactoring
This commit is contained in:
@@ -238,7 +238,7 @@ class File extends Entity
|
||||
],
|
||||
'primary key' => ['id'],
|
||||
'unique keys' => [
|
||||
'file_file_key' => ['file_hash', 'actor_id'],
|
||||
// 'file_file_key' => ['file_hash', 'actor_id'],
|
||||
],
|
||||
'indexes' => [
|
||||
'file_filehash_idx' => ['file_hash'],
|
||||
|
@@ -205,17 +205,23 @@ class GSActor extends Entity
|
||||
|
||||
public static function getFromId(int $id): ?self
|
||||
{
|
||||
return DB::find('gsactor', ['id' => $id]);
|
||||
return Cache::get('gsactor-id-' . $id, function () use ($id) {
|
||||
return DB::find('gsactor', ['id' => $id]);
|
||||
});
|
||||
}
|
||||
|
||||
public static function getFromNickname(string $nickname): ?self
|
||||
{
|
||||
return DB::findOneBy('gsactor', ['nickname' => $nickname]);
|
||||
return Cache::get('gsactor-nick-' . $nickname, function () use ($nickname) {
|
||||
return DB::findOneBy('gsactor', ['nickname' => $nickname]);
|
||||
});
|
||||
}
|
||||
|
||||
public static function getNicknameFromId(int $id): string
|
||||
{
|
||||
return self::getFromId($id)->getNickname();
|
||||
return Cache::get('gsactor-nick-id-' . $id, function () use ($id) {
|
||||
return self::getFromId($id)->getNickname();
|
||||
});
|
||||
}
|
||||
|
||||
public function getSelfTags(): array
|
||||
|
Reference in New Issue
Block a user