@@ -465,6 +465,8 @@ impl EventCacheStore for SqliteEventCacheStore {
465
465
key : & str ,
466
466
holder : & str ,
467
467
) -> Result < bool > {
468
+ let _timer = timer ! ( "method" ) ;
469
+
468
470
let key = key. to_owned ( ) ;
469
471
let holder = holder. to_owned ( ) ;
470
472
@@ -498,6 +500,8 @@ impl EventCacheStore for SqliteEventCacheStore {
498
500
linked_chunk_id : LinkedChunkId < ' _ > ,
499
501
updates : Vec < Update < Event , Gap > > ,
500
502
) -> Result < ( ) , Self :: Error > {
503
+ let _timer = timer ! ( "method" ) ;
504
+
501
505
// Use a single transaction throughout this function, so that either all updates
502
506
// work, or none is taken into account.
503
507
let hashed_linked_chunk_id =
@@ -826,6 +830,8 @@ impl EventCacheStore for SqliteEventCacheStore {
826
830
& self ,
827
831
linked_chunk_id : LinkedChunkId < ' _ > ,
828
832
) -> Result < Vec < RawChunk < Event , Gap > > , Self :: Error > {
833
+ let _timer = timer ! ( "method" ) ;
834
+
829
835
let hashed_linked_chunk_id =
830
836
self . encode_key ( keys:: LINKED_CHUNKS , linked_chunk_id. storage_key ( ) ) ;
831
837
@@ -868,6 +874,8 @@ impl EventCacheStore for SqliteEventCacheStore {
868
874
& self ,
869
875
linked_chunk_id : LinkedChunkId < ' _ > ,
870
876
) -> Result < Vec < ChunkMetadata > , Self :: Error > {
877
+ let _timer = timer ! ( "method" ) ;
878
+
871
879
let hashed_linked_chunk_id =
872
880
self . encode_key ( keys:: LINKED_CHUNKS , linked_chunk_id. storage_key ( ) ) ;
873
881
@@ -929,6 +937,8 @@ impl EventCacheStore for SqliteEventCacheStore {
929
937
& self ,
930
938
linked_chunk_id : LinkedChunkId < ' _ > ,
931
939
) -> Result < ( Option < RawChunk < Event , Gap > > , ChunkIdentifierGenerator ) , Self :: Error > {
940
+ let _timer = timer ! ( "method" ) ;
941
+
932
942
let hashed_linked_chunk_id =
933
943
self . encode_key ( keys:: LINKED_CHUNKS , linked_chunk_id. storage_key ( ) ) ;
934
944
@@ -1023,6 +1033,8 @@ impl EventCacheStore for SqliteEventCacheStore {
1023
1033
linked_chunk_id : LinkedChunkId < ' _ > ,
1024
1034
before_chunk_identifier : ChunkIdentifier ,
1025
1035
) -> Result < Option < RawChunk < Event , Gap > > , Self :: Error > {
1036
+ let _timer = timer ! ( "method" ) ;
1037
+
1026
1038
let hashed_linked_chunk_id =
1027
1039
self . encode_key ( keys:: LINKED_CHUNKS , linked_chunk_id. storage_key ( ) ) ;
1028
1040
@@ -1071,6 +1083,8 @@ impl EventCacheStore for SqliteEventCacheStore {
1071
1083
1072
1084
#[ instrument( skip( self ) ) ]
1073
1085
async fn clear_all_linked_chunks ( & self ) -> Result < ( ) , Self :: Error > {
1086
+ let _timer = timer ! ( "method" ) ;
1087
+
1074
1088
self . write ( )
1075
1089
. await ?
1076
1090
. with_transaction ( move |txn| {
@@ -1080,6 +1094,7 @@ impl EventCacheStore for SqliteEventCacheStore {
1080
1094
txn. execute ( "DELETE FROM events" , ( ) )
1081
1095
} )
1082
1096
. await ?;
1097
+
1083
1098
Ok ( ( ) )
1084
1099
}
1085
1100
@@ -1089,6 +1104,8 @@ impl EventCacheStore for SqliteEventCacheStore {
1089
1104
linked_chunk_id : LinkedChunkId < ' _ > ,
1090
1105
events : Vec < OwnedEventId > ,
1091
1106
) -> Result < Vec < ( OwnedEventId , Position ) > , Self :: Error > {
1107
+ let _timer = timer ! ( "method" ) ;
1108
+
1092
1109
// If there's no events for which we want to check duplicates, we can return
1093
1110
// early. It's not only an optimization to do so: it's required, otherwise the
1094
1111
// `repeat_vars` call below will panic.
@@ -1169,6 +1186,8 @@ impl EventCacheStore for SqliteEventCacheStore {
1169
1186
room_id : & RoomId ,
1170
1187
event_id : & EventId ,
1171
1188
) -> Result < Option < Event > , Self :: Error > {
1189
+ let _timer = timer ! ( "method" ) ;
1190
+
1172
1191
let event_id = event_id. to_owned ( ) ;
1173
1192
let this = self . clone ( ) ;
1174
1193
@@ -1200,6 +1219,8 @@ impl EventCacheStore for SqliteEventCacheStore {
1200
1219
event_id : & EventId ,
1201
1220
filters : Option < & [ RelationType ] > ,
1202
1221
) -> Result < Vec < ( Event , Option < Position > ) > , Self :: Error > {
1222
+ let _timer = timer ! ( "method" ) ;
1223
+
1203
1224
let hashed_room_id = self . encode_key ( keys:: LINKED_CHUNKS , room_id) ;
1204
1225
1205
1226
let hashed_linked_chunk_id =
@@ -1264,6 +1285,8 @@ impl EventCacheStore for SqliteEventCacheStore {
1264
1285
1265
1286
#[ instrument( skip( self , event) ) ]
1266
1287
async fn save_event ( & self , room_id : & RoomId , event : Event ) -> Result < ( ) , Self :: Error > {
1288
+ let _timer = timer ! ( "method" ) ;
1289
+
1267
1290
let Some ( event_id) = event. event_id ( ) else {
1268
1291
error ! ( %room_id, "Trying to save an event with no ID" ) ;
1269
1292
return Ok ( ( ) ) ;
@@ -1292,6 +1315,8 @@ impl EventCacheStore for SqliteEventCacheStore {
1292
1315
content : Vec < u8 > ,
1293
1316
ignore_policy : IgnoreMediaRetentionPolicy ,
1294
1317
) -> Result < ( ) > {
1318
+ let _timer = timer ! ( "method" ) ;
1319
+
1295
1320
self . media_service . add_media_content ( self , request, content, ignore_policy) . await
1296
1321
}
1297
1322
@@ -1301,6 +1326,8 @@ impl EventCacheStore for SqliteEventCacheStore {
1301
1326
from : & MediaRequestParameters ,
1302
1327
to : & MediaRequestParameters ,
1303
1328
) -> Result < ( ) , Self :: Error > {
1329
+ let _timer = timer ! ( "method" ) ;
1330
+
1304
1331
let prev_uri = self . encode_key ( keys:: MEDIA , from. source . unique_key ( ) ) ;
1305
1332
let prev_format = self . encode_key ( keys:: MEDIA , from. format . unique_key ( ) ) ;
1306
1333
@@ -1319,11 +1346,15 @@ impl EventCacheStore for SqliteEventCacheStore {
1319
1346
1320
1347
#[ instrument( skip_all) ]
1321
1348
async fn get_media_content ( & self , request : & MediaRequestParameters ) -> Result < Option < Vec < u8 > > > {
1349
+ let _timer = timer ! ( "method" ) ;
1350
+
1322
1351
self . media_service . get_media_content ( self , request) . await
1323
1352
}
1324
1353
1325
1354
#[ instrument( skip_all) ]
1326
1355
async fn remove_media_content ( & self , request : & MediaRequestParameters ) -> Result < ( ) > {
1356
+ let _timer = timer ! ( "method" ) ;
1357
+
1327
1358
let uri = self . encode_key ( keys:: MEDIA , request. source . unique_key ( ) ) ;
1328
1359
let format = self . encode_key ( keys:: MEDIA , request. format . unique_key ( ) ) ;
1329
1360
@@ -1338,11 +1369,15 @@ impl EventCacheStore for SqliteEventCacheStore {
1338
1369
& self ,
1339
1370
uri : & MxcUri ,
1340
1371
) -> Result < Option < Vec < u8 > > , Self :: Error > {
1372
+ let _timer = timer ! ( "method" ) ;
1373
+
1341
1374
self . media_service . get_media_content_for_uri ( self , uri) . await
1342
1375
}
1343
1376
1344
1377
#[ instrument( skip( self ) ) ]
1345
1378
async fn remove_media_content_for_uri ( & self , uri : & MxcUri ) -> Result < ( ) > {
1379
+ let _timer = timer ! ( "method" ) ;
1380
+
1346
1381
let uri = self . encode_key ( keys:: MEDIA , uri) ;
1347
1382
1348
1383
let conn = self . write ( ) . await ?;
@@ -1356,11 +1391,15 @@ impl EventCacheStore for SqliteEventCacheStore {
1356
1391
& self ,
1357
1392
policy : MediaRetentionPolicy ,
1358
1393
) -> Result < ( ) , Self :: Error > {
1394
+ let _timer = timer ! ( "method" ) ;
1395
+
1359
1396
self . media_service . set_media_retention_policy ( self , policy) . await
1360
1397
}
1361
1398
1362
1399
#[ instrument( skip_all) ]
1363
1400
fn media_retention_policy ( & self ) -> MediaRetentionPolicy {
1401
+ let _timer = timer ! ( "method" ) ;
1402
+
1364
1403
self . media_service . media_retention_policy ( )
1365
1404
}
1366
1405
@@ -1370,11 +1409,15 @@ impl EventCacheStore for SqliteEventCacheStore {
1370
1409
request : & MediaRequestParameters ,
1371
1410
ignore_policy : IgnoreMediaRetentionPolicy ,
1372
1411
) -> Result < ( ) , Self :: Error > {
1412
+ let _timer = timer ! ( "method" ) ;
1413
+
1373
1414
self . media_service . set_ignore_media_retention_policy ( self , request, ignore_policy) . await
1374
1415
}
1375
1416
1376
1417
#[ instrument( skip_all) ]
1377
1418
async fn clean_up_media_cache ( & self ) -> Result < ( ) , Self :: Error > {
1419
+ let _timer = timer ! ( "method" ) ;
1420
+
1378
1421
self . media_service . clean_up_media_cache ( self ) . await
1379
1422
}
1380
1423
}
0 commit comments