Skip to content

Commit 9054553

Browse files
authored
fix:Type Command Expired Key Consistency (#3132)
* Fix Type Command Expired Key Consistency * Change to English comments
1 parent 8b077fc commit 9054553

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/storage/src/redis_strings.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1671,7 +1671,14 @@ rocksdb::Status Redis::GetType(const storage::Slice& key, enum DataType& type) {
16711671
BaseMetaKey base_meta_key(key);
16721672
rocksdb::Status s = db_->Get(default_read_options_, handles_[kMetaCF], base_meta_key.Encode(), &meta_value);
16731673
if (s.ok()) {
1674-
type = static_cast<enum DataType>(static_cast<uint8_t>(meta_value[0]));
1674+
// Check if key has expired
1675+
if (ExpectedStale(meta_value)) {
1676+
type = DataType::kNones; // If key has expired, return "none" type
1677+
} else {
1678+
type = static_cast<enum DataType>(static_cast<uint8_t>(meta_value[0]));
1679+
}
1680+
} else {
1681+
type = DataType::kNones; // If key doesn't exist, return "none" type
16751682
}
16761683
return Status::OK();
16771684
}

0 commit comments

Comments
 (0)