FSTLevelDBQueryCache.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 "Firestore/core/src/firebase/firestore/model/types.h"
  21. #include "leveldb/db.h"
  22. @class FSTLevelDB;
  23. @class FSTLocalSerializer;
  24. @class FSTPBTargetGlobal;
  25. NS_ASSUME_NONNULL_BEGIN
  26. /** Cached Queries backed by LevelDB. */
  27. @interface FSTLevelDBQueryCache : NSObject <FSTQueryCache>
  28. /**
  29. * Retrieves the global singleton metadata row from the given database, if it exists.
  30. * TODO(gsoltis): remove this method once fully ported to transactions.
  31. */
  32. + (nullable FSTPBTargetGlobal *)readTargetMetadataFromDB:(leveldb::DB *)db;
  33. /**
  34. * Retrieves the global singleton metadata row using the given transaction, if it exists.
  35. */
  36. + (nullable FSTPBTargetGlobal *)readTargetMetadataWithTransaction:
  37. (firebase::firestore::local::LevelDbTransaction *)transaction;
  38. - (instancetype)init NS_UNAVAILABLE;
  39. /**
  40. * Creates a new query cache in the given LevelDB.
  41. *
  42. * @param db The LevelDB in which to create the cache.
  43. */
  44. - (instancetype)initWithDB:(FSTLevelDB *)db
  45. serializer:(FSTLocalSerializer *)serializer NS_DESIGNATED_INITIALIZER;
  46. /** Starts the query cache up. */
  47. - (void)start;
  48. - (void)enumerateOrphanedDocumentsUsingBlock:
  49. (void (^)(const firebase::firestore::model::DocumentKey &docKey,
  50. firebase::firestore::model::ListenSequenceNumber sequenceNumber,
  51. BOOL *stop))block;
  52. @end
  53. NS_ASSUME_NONNULL_END