MCPcopy Create free account
hub / github.com/F-Stack/f-stack / RM_GetClientUserNameById

Function RM_GetClientUserNameById

app/redis-6.2.6/src/module.c:1893–1909  ·  view source on GitHub ↗

Return the ACL user name used by the client with the specified client ID. * Client ID can be obtained with RM_GetClientId() API. If the client does not * exist, NULL is returned and errno is set to ENOENT. If the client isn't * using an ACL user, NULL is returned and errno is set to ENOTSUP */

Source from the content-addressed store, hash-verified

1891 * exist, NULL is returned and errno is set to ENOENT. If the client isn't
1892 * using an ACL user, NULL is returned and errno is set to ENOTSUP */
1893RedisModuleString *RM_GetClientUserNameById(RedisModuleCtx *ctx, uint64_t id) {
1894 client *client = lookupClientByID(id);
1895 if (client == NULL) {
1896 errno = ENOENT;
1897 return NULL;
1898 }
1899
1900 if (client->user == NULL) {
1901 errno = ENOTSUP;
1902 return NULL;
1903 }
1904
1905 sds name = sdsnew(client->user->name);
1906 robj *str = createObject(OBJ_STRING, name);
1907 autoMemoryAdd(ctx, REDISMODULE_AM_STRING, str);
1908 return str;
1909}
1910
1911/* This is an helper for RM_GetClientInfoById() and other functions: given
1912 * a client, it populates the client info structure with the appropriate

Callers

nothing calls this directly

Calls 4

lookupClientByIDFunction · 0.85
sdsnewFunction · 0.85
createObjectFunction · 0.85
autoMemoryAddFunction · 0.85

Tested by

no test coverage detected