change indentation and increase async mget threshold

Former-commit-id: ffaa176d5eafabfae372224c790e99dd9e520fef
This commit is contained in:
malavan 2021-08-25 22:15:28 +00:00
parent dcd3d47f7f
commit 7451f1738a

View File

@ -526,7 +526,7 @@ void getrangeCommand(client *c) {
void mgetCommand(client *c) { void mgetCommand(client *c) {
// Do async version for large number of arguments // Do async version for large number of arguments
if (c->argc > 1) { if (c->argc > 100) {
const redisDbPersistentDataSnapshot *snapshot = nullptr; const redisDbPersistentDataSnapshot *snapshot = nullptr;
if (!(c->flags & (CLIENT_MULTI | CLIENT_BLOCKED))) if (!(c->flags & (CLIENT_MULTI | CLIENT_BLOCKED)))
snapshot = c->db->createSnapshot(c->mvccCheckpoint, false /* fOptional */); snapshot = c->db->createSnapshot(c->mvccCheckpoint, false /* fOptional */);
@ -534,30 +534,30 @@ void mgetCommand(client *c) {
list *keys = listCreate(); list *keys = listCreate();
redisDb *db = c->db; redisDb *db = c->db;
c->asyncCommand( c->asyncCommand(
[c, keys] { [c, keys] {
for (int j = 1; j < c->argc; j++) { for (int j = 1; j < c->argc; j++) {
incrRefCount(c->argv[j]); incrRefCount(c->argv[j]);
listAddNodeTail(keys, c->argv[j]); listAddNodeTail(keys, c->argv[j]);
}
},
[c, keys, snapshot] {
addReplyArrayLen(c,listLength(keys));
listNode *ln = listFirst(keys);
while (ln != nullptr) {
robj_roptr o = snapshot->find_cached_threadsafe(szFromObj((robj*)listNodeValue(ln))).val();
if (o == nullptr || o->type != OBJ_STRING) {
addReplyNull(c);
} else {
addReplyBulk(c,o);
} }
ln = ln->next; },
[c, keys, snapshot] {
addReplyArrayLen(c,listLength(keys));
listNode *ln = listFirst(keys);
while (ln != nullptr) {
robj_roptr o = snapshot->find_cached_threadsafe(szFromObj((robj*)listNodeValue(ln))).val();
if (o == nullptr || o->type != OBJ_STRING) {
addReplyNull(c);
} else {
addReplyBulk(c,o);
}
ln = ln->next;
}
},
[keys, snapshot, db] {
db->endSnapshotAsync(snapshot);
listSetFreeMethod(keys,decrRefCountVoid);
listRelease(keys);
} }
},
[keys, snapshot, db] {
db->endSnapshotAsync(snapshot);
listSetFreeMethod(keys,decrRefCountVoid);
listRelease(keys);
}
); );
return; return;
} }