Skip to content

Commit 0ef9d58

Browse files
author
Liubov Didkivska
committed
Add caching versions infos
Add implementation to put/get versions list to catalog client cache. Implement versions infos cache tests. Relates-To: OLPEDGE-1606 Signed-off-by: Liubov Didkivska <ext-liubov.didkivska@here.com>
1 parent 5a9c5ee commit 0ef9d58

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

olp-cpp-sdk-dataservice-read/src/generated/parser/JsonParserCacheValue.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ template <typename T>
2828
inline T parse(const cache::KeyValueCache::ValueType& cached_json) {
2929
rapidjson::Document doc;
3030
T result{};
31-
if (!cached_json.empty() && cached_json.back() == '\0') {
32-
doc.Parse(reinterpret_cast<const char*>(cached_json.data()));
31+
if (!cached_json.empty()) {
32+
auto* data = static_cast<const void*>(cached_json.data());
33+
doc.Parse(static_cast<const char*>(data), cached_json.size());
3334
if (doc.IsObject() || doc.IsArray()) {
3435
from_json(doc, result);
3536
}

olp-cpp-sdk-dataservice-read/src/repositories/CatalogCacheRepository.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,8 @@ void CatalogCacheRepository::PutVersionInfos(
128128
OLP_SDK_LOG_DEBUG_F(kLogTag, "PutVersionInfos -> '%s'", key.c_str());
129129
auto list_versions = olp::serializer::serialize(versions);
130130

131-
// include null terminated symbol
132131
auto versions_data = std::make_shared<cache::KeyValueCache::ValueType>(
133-
list_versions.data(), list_versions.data() + list_versions.size() + 1);
132+
list_versions.data(), list_versions.data() + list_versions.size());
134133
cache_->Put(VersionInfosKey(hrn, start, end), versions_data, default_expiry_);
135134
}
136135

0 commit comments

Comments
 (0)