Skip to content

Commit

Permalink
Add caching versions infos
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Liubov Didkivska committed Jun 10, 2020
1 parent 5a9c5ee commit 0ef9d58
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ template <typename T>
inline T parse(const cache::KeyValueCache::ValueType& cached_json) {
rapidjson::Document doc;
T result{};
if (!cached_json.empty() && cached_json.back() == '\0') {
doc.Parse(reinterpret_cast<const char*>(cached_json.data()));
if (!cached_json.empty()) {
auto* data = static_cast<const void*>(cached_json.data());
doc.Parse(static_cast<const char*>(data), cached_json.size());
if (doc.IsObject() || doc.IsArray()) {
from_json(doc, result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,8 @@ void CatalogCacheRepository::PutVersionInfos(
OLP_SDK_LOG_DEBUG_F(kLogTag, "PutVersionInfos -> '%s'", key.c_str());
auto list_versions = olp::serializer::serialize(versions);

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

Expand Down

0 comments on commit 0ef9d58

Please sign in to comment.