MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / hashTypeExists

Function hashTypeExists

src/t_hash.cpp:172–185  ·  view source on GitHub ↗

Test if the specified field exists in the given hash. Returns 1 if the field * exists, and 0 when it doesn't. */

Source from the content-addressed store, hash-verified

170/* Test if the specified field exists in the given hash. Returns 1 if the field
171 * exists, and 0 when it doesn't. */
172int hashTypeExists(robj_roptr o, const char *field) {
173 if (o->encoding == OBJ_ENCODING_ZIPLIST) {
174 const unsigned char *vstr = NULL;
175 unsigned int vlen = UINT_MAX;
176 long long vll = LLONG_MAX;
177
178 if (hashTypeGetFromZiplist(o, field, &vstr, &vlen, &vll) == 0) return 1;
179 } else if (o->encoding == OBJ_ENCODING_HT) {
180 if (hashTypeGetFromHashTable(o, field) != NULL) return 1;
181 } else {
182 serverPanic("Unknown hash encoding");
183 }
184 return 0;
185}
186
187/* Add a new field, overwrite the old with the new value if it already exists.
188 * Return 0 on insert and 1 on update.

Callers 5

hsetnxCommandFunction · 0.85
hexistsCommandFunction · 0.85
expireMemberCoreFunction · 0.85
RM_HashSetFunction · 0.85
RM_HashGetFunction · 0.85

Calls 2

hashTypeGetFromZiplistFunction · 0.85
hashTypeGetFromHashTableFunction · 0.85

Tested by

no test coverage detected