Skip to content

Commit

Permalink
Merge branch 'unstable' into skip_cache_dtor
Browse files Browse the repository at this point in the history
  • Loading branch information
git-hulk authored Dec 3, 2024
2 parents 1f8af3a + 1ed45bc commit d39e5b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/types/redis_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ rocksdb::Status String::getRawValue(engine::Context &ctx, const std::string &ns_

Metadata metadata(kRedisNone, false);
Slice slice = *raw_value;
return ParseMetadataWithStats({kRedisString}, &slice, &metadata);
s = ParseMetadataWithStats({kRedisString}, &slice, &metadata);
if (!s.ok()) raw_value->clear();
return s;
}

rocksdb::Status String::getValueAndExpire(engine::Context &ctx, const std::string &ns_key, std::string *value,
Expand Down Expand Up @@ -329,7 +331,6 @@ rocksdb::Status String::IncrBy(engine::Context &ctx, const std::string &user_key
if (!s.ok() && !s.IsNotFound()) return s;
if (s.IsNotFound()) {
Metadata metadata(kRedisString, false);
raw_value.clear();
metadata.Encode(&raw_value);
}

Expand Down Expand Up @@ -368,7 +369,6 @@ rocksdb::Status String::IncrByFloat(engine::Context &ctx, const std::string &use

if (s.IsNotFound()) {
Metadata metadata(kRedisString, false);
raw_value.clear();
metadata.Encode(&raw_value);
}
size_t offset = Metadata::GetOffsetAfterExpire(raw_value[0]);
Expand Down
9 changes: 9 additions & 0 deletions tests/cppunit/types/string_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,15 @@ TEST_F(RedisStringTest, SetRange) {
string_->Get(*ctx_, key_, &value);
EXPECT_EQ(16, value.size());
auto s = string_->Del(*ctx_, key_);

string_->SetEX(*ctx_, key_, "test-value", 1);
sleep(2);
s = string_->Get(*ctx_, key_, &value);
EXPECT_TRUE(s.IsNotFound());
string_->SetRange(*ctx_, key_, 0, "12345", &ret);
EXPECT_EQ(5, ret);
string_->Get(*ctx_, key_, &value);
EXPECT_EQ("12345", value);
}

TEST_F(RedisStringTest, CAS) {
Expand Down

0 comments on commit d39e5b9

Please sign in to comment.