Better update in memory cache

This commit is contained in:
laurenspriem
2025-05-30 16:55:48 +05:30
parent ba468d32f5
commit 2c50b84e30
3 changed files with 15 additions and 9 deletions

View File

@@ -1286,6 +1286,8 @@ class MLDataDB with SqlDbBase implements IMLDataDB<int> {
];
}
/// WARNING: Better to use the similarly named [putFaceIdCachedForPersonOrCluster]
/// method from face_thumbnail_cache instead!
Future<void> putFaceIdCachedForPersonOrCluster(
String personOrClusterId,
String faceID,

View File

@@ -443,10 +443,7 @@ class PersonService {
data: person.data.copyWith(avatarFaceId: face.faceID),
);
await updatePerson(updatedPerson);
await faceMLDataDB.putFaceIdCachedForPersonOrCluster(
p.remoteID,
face.faceID,
);
await putFaceIdCachedForPersonOrCluster(p.remoteID, face.faceID);
return updatedPerson;
}

View File

@@ -65,6 +65,17 @@ Future<String?> checkUsedFaceIDForPersonOrClusterId(
return faceIDFromDB;
}
Future<void> putFaceIdCachedForPersonOrCluster(
String personOrClusterID,
String faceID,
) async {
await MLDataDB.instance.putFaceIdCachedForPersonOrCluster(
personOrClusterID,
faceID,
);
_personOrClusterIdToCachedFaceID.put(personOrClusterID, faceID);
}
Future<void> _putCachedCropForFaceID(
String faceID,
Uint8List data, [
@@ -72,11 +83,7 @@ Future<void> _putCachedCropForFaceID(
]) async {
_faceCropCache.put(faceID, data);
if (personOrClusterID != null) {
await MLDataDB.instance.putFaceIdCachedForPersonOrCluster(
personOrClusterID,
faceID,
);
_personOrClusterIdToCachedFaceID.put(personOrClusterID, faceID);
await putFaceIdCachedForPersonOrCluster(personOrClusterID, faceID);
}
}