FSTLevelDBQueryCache.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #include <memory>
  18. #import "Firestore/Source/Local/FSTQueryCache.h"
  19. #include "Firestore/core/src/firebase/firestore/local/leveldb_transaction.h"
  20. #include "leveldb/db.h"
  21. @class FSTLevelDB;
  22. @class FSTLocalSerializer;
  23. @class FSTPBTargetGlobal;
  24. NS_ASSUME_NONNULL_BEGIN
  25. /** Cached Queries backed by LevelDB. */
  26. @interface FSTLevelDBQueryCache : NSObject <FSTQueryCache>
  27. /**
  28. * Retrieves the global singleton metadata row from the given database, if it exists.
  29. * TODO(gsoltis): remove this method once fully ported to transactions.
  30. */
  31. + (nullable FSTPBTargetGlobal *)readTargetMetadataFromDB:(leveldb::DB *)db;
  32. /**
  33. * Retrieves the global singleton metadata row using the given transaction, if it exists.
  34. */
  35. + (nullable FSTPBTargetGlobal *)readTargetMetadataWithTransaction:
  36. (firebase::firestore::local::LevelDbTransaction *)transaction;
  37. - (instancetype)init NS_UNAVAILABLE;
  38. /**
  39. * Creates a new query cache in the given LevelDB.
  40. *
  41. * @param db The LevelDB in which to create the cache.
  42. */
  43. - (instancetype)initWithDB:(FSTLevelDB *)db
  44. serializer:(FSTLocalSerializer *)serializer NS_DESIGNATED_INITIALIZER;
  45. /** Starts the query cache up. */
  46. - (void)start;
  47. - (void)enumerateOrphanedDocumentsUsingBlock:
  48. (void (^)(const firebase::firestore::model::DocumentKey &docKey,
  49. FSTListenSequenceNumber sequenceNumber,
  50. BOOL *stop))block;
  51. @end
  52. NS_ASSUME_NONNULL_END