mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 18:35:46 +02:00
chore: improve compatibility of EXPIRE functions with Redis (#2696)
* chore: improve compatibility of EXPIRE functions with Redis Also, provide a module name if stumbled upon module data that can not be loaded by dragonfly. --------- Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
4a9f816106
commit
d709f2a911
5 changed files with 60 additions and 20 deletions
|
@ -203,6 +203,25 @@ int ziplistPairsConvertAndValidateIntegrity(const uint8_t* zl, size_t size, unsi
|
|||
return ret;
|
||||
}
|
||||
|
||||
string ModuleTypeName(uint64_t module_id) {
|
||||
static const char ModuleNameSet[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789-_";
|
||||
|
||||
char name[10];
|
||||
|
||||
name[9] = '\0';
|
||||
char* p = name + 8;
|
||||
module_id >>= 10;
|
||||
for (int j = 0; j < 9; j++) {
|
||||
*p-- = ModuleNameSet[module_id & 63];
|
||||
module_id >>= 6;
|
||||
}
|
||||
|
||||
return string{name};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
class DecompressImpl {
|
||||
|
@ -1978,7 +1997,11 @@ error_code RdbLoader::Load(io::Source* src) {
|
|||
}
|
||||
|
||||
if (type == RDB_OPCODE_MODULE_AUX) {
|
||||
LOG(ERROR) << "Modules are not supported";
|
||||
uint64_t module_id;
|
||||
SET_OR_RETURN(LoadLen(nullptr), module_id);
|
||||
string module_name = ModuleTypeName(module_id);
|
||||
|
||||
LOG(ERROR) << "Modules are not supported, error loading module " << module_name;
|
||||
return RdbError(errc::feature_not_supported);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue