From 5f5f80825820487e1c7ed964c94a472e84adc552 Mon Sep 17 00:00:00 2001 From: Greg Soltis Date: Tue, 13 Feb 2018 11:12:17 -0800 Subject: Keep track of number of queries in the query cache (#776) * Implement schema versions * Style fixes * newlines, copyrights, assumptions * Fix nullability * Raw ptr -> shared_ptr * kVersionTableGlobal -> kVersionGlobalTable * Drop utils, move into static methods * Drop extra include * Add a few more comments * Move version constant into migrations file * formatting? * Fix comment * Split add and update queryData * Work on adding targetCount * More work on count * Using shared_ptr * Implement count for query cache * use quotes * Add cast * Styling * Revert year bump in copyright * Add adversarial key to migration test * Add comment * Fix style --- Firestore/Source/Local/FSTQueryCache.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'Firestore/Source/Local/FSTQueryCache.h') diff --git a/Firestore/Source/Local/FSTQueryCache.h b/Firestore/Source/Local/FSTQueryCache.h index 88c9df9..5c43de4 100644 --- a/Firestore/Source/Local/FSTQueryCache.h +++ b/Firestore/Source/Local/FSTQueryCache.h @@ -78,18 +78,29 @@ NS_ASSUME_NONNULL_BEGIN group:(FSTWriteGroup *)group; /** - * Adds or replaces an entry in the cache. + * Adds an entry in the cache. * - * The cache key is extracted from `queryData.query`. If there is already a cache entry for the - * key, it will be replaced. + * The cache key is extracted from `queryData.query`. The key must not already exist in the cache. * - * @param queryData An FSTQueryData instance to put in the cache. + * @param queryData A new FSTQueryData instance to put in the cache. */ - (void)addQueryData:(FSTQueryData *)queryData group:(FSTWriteGroup *)group; +/** + * Updates an entry in the cache. + * + * The cache key is extracted from `queryData.query`. The entry must already exist in the cache, + * and it will be replaced. + * @param queryData An FSTQueryData instance to replace an existing entry in the cache + */ +- (void)updateQueryData:(FSTQueryData *)queryData group:(FSTWriteGroup *)group; + /** Removes the cached entry for the given query data (no-op if no entry exists). */ - (void)removeQueryData:(FSTQueryData *)queryData group:(FSTWriteGroup *)group; +/** Returns the number of targets cached. */ +- (int32_t)count; + /** * Looks up an FSTQueryData entry in the cache. * -- cgit v1.2.3