FSTLevelDBQueryCache.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. @protocol FSTGarbageCollector;
  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:(std::shared_ptr<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. /** The garbage collector to notify about potential garbage keys. */
  40. @property(nonatomic, weak, readwrite, nullable) id<FSTGarbageCollector> garbageCollector;
  41. /**
  42. * Creates a new query cache in the given LevelDB.
  43. *
  44. * @param db The LevelDB in which to create the cache.
  45. */
  46. - (instancetype)initWithDB:(FSTLevelDB *)db
  47. serializer:(FSTLocalSerializer *)serializer NS_DESIGNATED_INITIALIZER;
  48. @end
  49. NS_ASSUME_NONNULL_END