π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Remove unnecessary cache lock from text embeddings service
laurenspriemc691b545a2fe
diff --git a/mobile/apps/photos/lib/services/text_embeddings_cache_service.dart b/mobile/apps/photos/lib/services/text_embeddings_cache_service.dartindex 475da9a76b..1fa450f751 100644--- a/mobile/apps/photos/lib/services/text_embeddings_cache_service.dart+++ b/mobile/apps/photos/lib/services/text_embeddings_cache_service.dart@@ -1,36 +1,29 @@-import 'dart:async';-import 'package:logging/logging.dart';import 'package:photos/db/ml/db.dart';import 'package:photos/services/machine_learning/ml_computer.dart';-import 'package:synchronized/synchronized.dart';class TextEmbeddingsCacheService {static final _logger = Logger('TextEmbeddingsCacheService');- final _cacheLock = Lock();-TextEmbeddingsCacheService._privateConstructor();static final instance = TextEmbeddingsCacheService._privateConstructor();Future<List<double>> getEmbedding(String query) async {- return _cacheLock.synchronized(() async {- // 1. Check database cache- final dbResult =- await MLDataDB.instance.getRepeatedTextEmbeddingCache(query);- if (dbResult != null) {- _logger.info('Text embedding cache hit for query');- return dbResult;- }-- // 2. Compute new embedding- _logger.info('Computing new text embedding for query');- final embedding = await MLComputer.instance.runClipText(query);-- // 3. Store in database cache- await MLDataDB.instance.putRepeatedTextEmbeddingCache(query, embedding);-- return embedding;- });+ // 1. Check database cache+ final dbResult =+ await MLDataDB.instance.getRepeatedTextEmbeddingCache(query);+ if (dbResult != null) {+ _logger.info('Text embedding cache hit for query');+ return dbResult;+ }++ // 2. Compute new embedding+ _logger.info('Computing new text embedding for query');+ final embedding = await MLComputer.instance.runClipText(query);++ // 3. Store in database cache+ await MLDataDB.instance.putRepeatedTextEmbeddingCache(query, embedding);++ return embedding;}}