Skip to content

Commit 457f4db

Browse files
amabluea-maurice
authored andcommitted
Added a no-op persistence engine, which is used for backing the .info sync
tree. These values are not backed to disk, so the persistence engine that backs them simply does nothing. PiperOrigin-RevId: 257092697
1 parent 7e0b30e commit 457f4db

File tree

3 files changed

+176
-0
lines changed

3 files changed

+176
-0
lines changed

database/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ set(desktop_SRCS
104104
src/desktop/disconnection_desktop.cc
105105
src/desktop/mutable_data_desktop.cc
106106
src/desktop/persistence/in_memory_persistence_storage_engine.cc
107+
src/desktop/persistence/noop_persistence_storage_engine.cc
107108
src/desktop/persistence/persistence_manager.cc
108109
src/desktop/push_child_name_generator.cc
109110
src/desktop/query_desktop.cc
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// Copyright 2019 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "database/src/desktop/persistence/noop_persistence_storage_engine.h"
16+
17+
namespace firebase {
18+
namespace database {
19+
namespace internal {
20+
21+
NoopPersistenceStorageEngine::~NoopPersistenceStorageEngine() {}
22+
23+
void NoopPersistenceStorageEngine::SaveUserOverwrite(const Path& path,
24+
const Variant& data,
25+
WriteId write_id) {}
26+
27+
void NoopPersistenceStorageEngine::SaveUserMerge(const Path& path,
28+
const CompoundWrite& children,
29+
WriteId write_id) {}
30+
31+
void NoopPersistenceStorageEngine::RemoveUserWrite(WriteId write_id) {}
32+
33+
std::vector<UserWriteRecord> NoopPersistenceStorageEngine::LoadUserWrites() {
34+
return std::vector<UserWriteRecord>();
35+
}
36+
37+
void NoopPersistenceStorageEngine::RemoveAllUserWrites() {}
38+
39+
const Variant& NoopPersistenceStorageEngine::ServerCache(const Path& path) {
40+
return kNullVariant;
41+
}
42+
43+
void NoopPersistenceStorageEngine::OverwriteServerCache(const Path& path,
44+
const Variant& data) {}
45+
46+
void NoopPersistenceStorageEngine::MergeIntoServerCache(const Path& path,
47+
const Variant& data) {}
48+
49+
void NoopPersistenceStorageEngine::MergeIntoServerCache(
50+
const Path& path, const CompoundWrite& children) {}
51+
52+
void NoopPersistenceStorageEngine::SaveTrackedQuery(
53+
const TrackedQuery& tracked_query) {}
54+
55+
void NoopPersistenceStorageEngine::DeleteTrackedQuery(QueryId query_id) {}
56+
57+
std::vector<TrackedQuery> NoopPersistenceStorageEngine::LoadTrackedQueries() {
58+
return std::vector<TrackedQuery>();
59+
}
60+
61+
void NoopPersistenceStorageEngine::ResetPreviouslyActiveTrackedQueries(
62+
uint64_t last_use) {}
63+
64+
void NoopPersistenceStorageEngine::SaveTrackedQueryKeys(
65+
QueryId query_id, const std::set<std::string>& keys) {}
66+
67+
void NoopPersistenceStorageEngine::UpdateTrackedQueryKeys(
68+
QueryId query_id, const std::set<std::string>& added,
69+
const std::set<std::string>& removed) {}
70+
71+
std::set<std::string> NoopPersistenceStorageEngine::LoadTrackedQueryKeys(
72+
QueryId query_id) {
73+
return std::set<std::string>();
74+
}
75+
76+
std::set<std::string> NoopPersistenceStorageEngine::LoadTrackedQueryKeys(
77+
const std::set<QueryId>& query_ids) {
78+
return std::set<std::string>();
79+
}
80+
81+
bool NoopPersistenceStorageEngine::BeginTransaction() { return true; }
82+
83+
void NoopPersistenceStorageEngine::EndTransaction() {}
84+
85+
void NoopPersistenceStorageEngine::SetTransactionSuccessful() {}
86+
87+
} // namespace internal
88+
} // namespace database
89+
} // namespace firebase
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Copyright 2019 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef FIREBASE_DATABASE_CLIENT_CPP_SRC_DESKTOP_PERSISTENCE_NOOP_PERSISTENCE_STORAGE_ENGINE_H_
16+
#define FIREBASE_DATABASE_CLIENT_CPP_SRC_DESKTOP_PERSISTENCE_NOOP_PERSISTENCE_STORAGE_ENGINE_H_
17+
18+
#include <cstdint>
19+
#include <set>
20+
21+
#include "app/src/include/firebase/variant.h"
22+
#include "app/src/path.h"
23+
#include "database/src/desktop/core/compound_write.h"
24+
#include "database/src/desktop/persistence/persistence_storage_engine.h"
25+
26+
namespace firebase {
27+
namespace database {
28+
namespace internal {
29+
30+
class NoopPersistenceStorageEngine : public PersistenceStorageEngine {
31+
public:
32+
~NoopPersistenceStorageEngine() override;
33+
34+
void SaveUserOverwrite(const Path& path, const Variant& data,
35+
WriteId write_id) override;
36+
37+
void SaveUserMerge(const Path& path, const CompoundWrite& children,
38+
WriteId write_id) override;
39+
40+
void RemoveUserWrite(WriteId write_id) override;
41+
42+
std::vector<UserWriteRecord> LoadUserWrites() override;
43+
44+
void RemoveAllUserWrites() override;
45+
46+
const Variant& ServerCache(const Path& path) override;
47+
48+
void OverwriteServerCache(const Path& path, const Variant& data) override;
49+
50+
void MergeIntoServerCache(const Path& path, const Variant& data) override;
51+
52+
void MergeIntoServerCache(const Path& path,
53+
const CompoundWrite& children) override;
54+
55+
void SaveTrackedQuery(const TrackedQuery& tracked_query) override;
56+
57+
void DeleteTrackedQuery(QueryId query_id) override;
58+
59+
std::vector<TrackedQuery> LoadTrackedQueries() override;
60+
61+
void ResetPreviouslyActiveTrackedQueries(uint64_t last_use) override;
62+
63+
void SaveTrackedQueryKeys(QueryId query_id,
64+
const std::set<std::string>& keys) override;
65+
66+
void UpdateTrackedQueryKeys(QueryId query_id,
67+
const std::set<std::string>& added,
68+
const std::set<std::string>& removed) override;
69+
70+
std::set<std::string> LoadTrackedQueryKeys(QueryId query_id) override;
71+
72+
std::set<std::string> LoadTrackedQueryKeys(
73+
const std::set<QueryId>& query_ids) override;
74+
75+
bool BeginTransaction() override;
76+
77+
void EndTransaction() override;
78+
79+
void SetTransactionSuccessful() override;
80+
};
81+
82+
} // namespace internal
83+
} // namespace database
84+
} // namespace firebase
85+
86+
#endif // FIREBASE_DATABASE_CLIENT_CPP_SRC_DESKTOP_PERSISTENCE_NOOP_PERSISTENCE_STORAGE_ENGINE_H_

0 commit comments

Comments
 (0)