-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: floyd supports "Within the same Redis database, a single key name can only have one type of data structure" #2609
feat: floyd supports "Within the same Redis database, a single key name can only have one type of data structure" #2609
Conversation
342c292
to
f98930f
Compare
50d9c4b
to
d22ff2f
Compare
cf4de66
to
25b900a
Compare
2f7a9c8
to
0e6b16f
Compare
0e6b16f
to
4234335
Compare
else if (s_.ToString() == ErrTypeMessage) {
res_.SetRes(CmdRes::kMultiKey);
}
// 修改前:
std::string CachePrefixKeyK = PCacheKeyPrefixK + key_;
db_->cache()->SetBitIfKeyExist(CachePrefixKeyK, bit_offset_, on_);
// 修改后
db_->cache()->SetBitIfKeyExist(key_, bit_offset_, on_);
修改前:
// Keys Commands
int32_t Storage::Expire(const Slice& key, int64_t ttl, std::map<DataType, Status>* type_status) {
type_status->clear();
int32_t ret = 0;
bool is_corruption = false;
auto& inst = GetDBInstance(key);
// Strings
Status s = inst->StringsExpire(key, ttl);
if (s.ok()) {
ret++;
} else if (!s.IsNotFound()) {
is_corruption = true;
(*type_status)[DataType::kStrings] = s;
}
// Hash
s = inst->HashesExpire(key, ttl);
if (s.ok()) {
ret++;
} else if (!s.IsNotFound()) {
is_corruption = true;
(*type_status)[DataType::kHashes] = s;
}
// Sets
s = inst->SetsExpire(key, ttl);
if (s.ok()) {
ret++;
} else if (!s.IsNotFound()) {
is_corruption = true;
(*type_status)[DataType::kSets] = s;
}
// Lists
s = inst->ListsExpire(key, ttl);
if (s.ok()) {
ret++;
} else if (!s.IsNotFound()) {
is_corruption = true;
(*type_status)[DataType::kLists] = s;
}
// Zsets
s = inst->ZsetsExpire(key, ttl);
if (s.ok()) {
ret++;
} else if (!s.IsNotFound()) {
is_corruption = true;
(*type_status)[DataType::kZSets] = s;
}
if (is_corruption) {
return -1;
} else {
return ret;
}
}
修改后
// Keys Commands
int32_t Storage::Expire(const Slice& key, int64_t ttl) {
auto& inst = GetDBInstance(key);
Status s = inst->Expire(key, ttl);
if (s.ok()) {
return 1;
} else if (!s.IsNotFound()) {
return -1;
}
return 1;
}
if (!ExpectedMetaValue(Type::kSet, meta_value)) {
return Status::InvalidArgument("WRONGTYPE Operation against a key holding the wrong kind of value");
} |
36b9ffe
to
ad99b09
Compare
269e045
to
af67771
Compare
df416fc
to
53dd707
Compare
@@ -1242,7 +1242,7 @@ int64_t Storage::Scan(const DataType& dtype, int64_t cursor, const std::string& | |||
LOG(WARNING) << "Invalid key_type: " << key_type; | |||
return 0; | |||
} | |||
std::copy(pos, iter_end, std::back_inserter(types)); | |||
std::copy(pos, iter_end - 2, std::back_inserter(types)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个地方为什么减2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是因为之前DataType类型只有all+五种数据类型,然后现在我复用了这个DataType需要加一个none类型,然后-2是因为之前可以直接到迭代器尾端,但是现在得在末端前两个
0f46c45
to
8380ad5
Compare
src/pika_kv.cc
Outdated
@@ -224,19 +222,15 @@ void DelCmd::DoUpdateCache() { | |||
if (s_.ok()) { | |||
std::vector<std::string> v; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里既然只存在一种类型,那直接delete key就好了,没必要用v转换一下
src/pika_list.cc
Outdated
@@ -663,6 +676,10 @@ void BRPopCmd::Do() { | |||
return; | |||
} else if (s_.IsNotFound()) { | |||
continue; | |||
} else if (s_.IsInvalidArgument()) { | |||
// TODO use return or continue; Mixficsol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里确认了 就把注释删了吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
…me can only have one type of data structure" (OpenAtomFoundation#2609) * floyd supports one key for one data structure * Modified the criteria for determining multiple keys
…me can only have one type of data structure" (OpenAtomFoundation#2609) * floyd supports one key for one data structure * Modified the criteria for determining multiple keys
背景
当前
Pika
的一个Key
可以对应多种数据结构,和Redis
不一致解决方案
在
Floyd
现有的设计之上,将之前String
类型所在的Column-Family
用于存放所有的Key
的Meta
信息kMetaCF 字段设计
修改前
String
Hash
List
set
zset
Stream
修改后
我们对每一种数据类型的
Meta
的value
前增加一个字段Type
用于区别每个Key
对应的数据结构以
Set
类型举例String 的 Meta 格式
在解析的时候,先解析头部的第一个字节,然后根据类型判断是否需要继续解析下去