mirror of https://mirror.osredm.com/root/redis.git
Merge 9b7c45cf49
into 6995d8ac17
This commit is contained in:
commit
4a84d410d5
21
src/t_hash.c
21
src/t_hash.c
|
@ -926,8 +926,10 @@ int hashTypeSet(redisDb *db, robj *o, sds field, sds value, int flags) {
|
|||
}
|
||||
o->ptr = zl;
|
||||
|
||||
/* Check if the listpack needs to be converted to a hash table */
|
||||
if (hashTypeLength(o, 0) > server.hash_max_listpack_entries)
|
||||
/* Check if the listpack needs to be converted to a hash table.
|
||||
* We do not subtract expired field here, if there is no new field inserted,
|
||||
* we also skip recomputing the listpack element count, avoiding unnecessary overhead. */
|
||||
if (!update && hashTypeLength(o, 0) > server.hash_max_listpack_entries)
|
||||
hashTypeConvert(o, OBJ_ENCODING_HT, &db->hexpires);
|
||||
} else if (o->encoding == OBJ_ENCODING_LISTPACK_EX) {
|
||||
unsigned char *fptr = NULL, *vptr = NULL, *tptr = NULL;
|
||||
|
@ -961,14 +963,15 @@ int hashTypeSet(redisDb *db, robj *o, sds field, sds value, int flags) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!update)
|
||||
if (!update) {
|
||||
listpackExAddNew(o, field, sdslen(field), value, sdslen(value),
|
||||
HASH_LP_NO_TTL);
|
||||
|
||||
/* Check if the listpack needs to be converted to a hash table */
|
||||
if (hashTypeLength(o, 0) > server.hash_max_listpack_entries)
|
||||
hashTypeConvert(o, OBJ_ENCODING_HT, &db->hexpires);
|
||||
|
||||
/* Check if the listpack needs to be converted to a hash table.
|
||||
* We do not subtract expired field here, if there is no new field inserted,
|
||||
* we also skip recomputing the listpack element count, avoiding unnecessary overhead. */
|
||||
if (hashTypeLength(o, 0) > server.hash_max_listpack_entries)
|
||||
hashTypeConvert(o, OBJ_ENCODING_HT, &db->hexpires);
|
||||
}
|
||||
} else if (o->encoding == OBJ_ENCODING_HT) {
|
||||
dict *ht = o->ptr;
|
||||
dictEntry *de;
|
||||
|
@ -1002,7 +1005,7 @@ int hashTypeSet(redisDb *db, robj *o, sds field, sds value, int flags) {
|
|||
serverPanic("Unknown hash encoding");
|
||||
}
|
||||
|
||||
/* Free SDS strings we did not referenced elsewhere if the flags
|
||||
/* Free SDS strings we did not reference elsewhere if the flags
|
||||
* want this function to be responsible. */
|
||||
if (flags & HASH_SET_TAKE_FIELD && field) sdsfree(field);
|
||||
if (flags & HASH_SET_TAKE_VALUE && value) sdsfree(value);
|
||||
|
|
Loading…
Reference in New Issue