Skip to content

Commit

Permalink
Revert "fix: fix ExpectedStale error when expired type is string (#2682
Browse files Browse the repository at this point in the history
…)"

This reverts commit 2962bf4.
  • Loading branch information
AlexStocks authored May 29, 2024
1 parent 2962bf4 commit 1ccb4d1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
15 changes: 9 additions & 6 deletions src/storage/src/redis.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,16 +406,19 @@ class Redis {
auto meta_type = static_cast<enum DataType>(static_cast<uint8_t>(meta_value[0]));
if (meta_type == DataType::kZSets || meta_type == DataType::kSets || meta_type == DataType::kHashes) {
ParsedBaseMetaValue parsed_meta_value(meta_value);
return (parsed_meta_value.IsStale() || parsed_meta_value.Count() == 0);
if (parsed_meta_value.IsStale() || parsed_meta_value.Count() == 0) {
return true;
}
} else if (meta_type == DataType::kLists) {
ParsedListsMetaValue parsed_lists_meta_value(meta_value);
return (parsed_lists_meta_value.IsStale() || parsed_lists_meta_value.Count() == 0);
} else if (meta_type == DataType::kStrings) {
ParsedStringsValue parsed_strings_value(meta_value);
return parsed_strings_value.IsStale();
if (parsed_lists_meta_value.IsStale() || parsed_lists_meta_value.Count() == 0) {
return true;
}
} else if (meta_type == DataType::kStreams) {
StreamMetaValue stream_meta_value;
return stream_meta_value.length() == 0;
if (stream_meta_value.length() == 0) {
return true;
}
}
return false;
}
Expand Down
9 changes: 0 additions & 9 deletions src/storage/tests/hashes_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -875,15 +875,6 @@ TEST_F(HashesTest, HSetTest) {
s = db.HGet("GP3_HSET_KEY", "HSET_TEST_NEW_FIELD", &value);
ASSERT_TRUE(s.ok());
ASSERT_EQ(value, "HSET_TEST_NEW_VALUE");

// ***************** Group 4 Test *****************
// hset after string type key expires, should success
s = db.Setex("GP4_HSET_KEY", "STRING_VALUE_WITH_TTL", 1);
ASSERT_TRUE(s.ok());
std::this_thread::sleep_for(std::chrono::milliseconds(2100));
s = db.HSet("GP4_HSET_KEY", "HSET_TEST_NEW_FIELD", "HSET_TEST_NEW_VALUE", &ret);
ASSERT_TRUE(s.ok());
ASSERT_EQ(ret, 1);
}

// HSetnx
Expand Down

0 comments on commit 1ccb4d1

Please sign in to comment.