Line data Source code
1 : import { QUERY_CACHE_DELETED } from '../../query/query_execution_state.js';
2 : import type { ConnectionRegistry, DynamicConnectionDispatch } from '../../connections/connection_registry.js';
3 :
4 : /// Mark the finished queries whose cached results were deleted, their results no longer advertise a cache entry. The
5 : /// cache belongs to the app, the queries of every connection may advertise a key. Returns the number of marked queries.
6 1 : export function markDeletedQueryResults(
7 1 : registry: ConnectionRegistry,
8 1 : dispatch: DynamicConnectionDispatch,
9 1 : keys: Iterable<string>,
10 1 : ): number {
11 1 : const deleted = new Set(keys);
12 1 : let marked = 0;
13 1 : for (const database of registry.connections.values()) {
14 1 : for (const query of database.queriesFinished.values()) {
15 1 : if (query.cacheKey != null && deleted.has(query.cacheKey) && !query.cacheDeleted) {
16 1 : dispatch(database.connectionId, { type: QUERY_CACHE_DELETED, value: [query.queryId] });
17 1 : ++marked;
18 1 : }
19 : }
20 : }
21 1 : return marked;
22 1 : }
|