Higher level function of hashTypeGet*() that returns the hash value * associated with the specified field. If the field is found C_OK * is returned, otherwise C_ERR. The returned object is returned by * reference in either *vstr and *vlen if it's returned in string form, * or stored in *vll if it's returned as a number. * * If *vll is populated *vstr is set to NULL, so the caller * can alwa
| 113 | * can always check the function return by checking the return value |
| 114 | * for C_OK and checking if vll (or vstr) is NULL. */ |
| 115 | int hashTypeGetValue(robj_roptr o, sds field, const unsigned char **vstr, unsigned int *vlen, long long *vll) { |
| 116 | if (o->encoding == OBJ_ENCODING_ZIPLIST) { |
| 117 | *vstr = NULL; |
| 118 | if (hashTypeGetFromZiplist(o, field, vstr, vlen, vll) == 0) |
| 119 | return C_OK; |
| 120 | } else if (o->encoding == OBJ_ENCODING_HT) { |
| 121 | const char *value; |
| 122 | if ((value = hashTypeGetFromHashTable(o, field)) != NULL) { |
| 123 | *vstr = (const unsigned char*) value; |
| 124 | *vlen = sdslen(value); |
| 125 | return C_OK; |
| 126 | } |
| 127 | } else { |
| 128 | serverPanic("Unknown hash encoding"); |
| 129 | } |
| 130 | return C_ERR; |
| 131 | } |
| 132 | |
| 133 | /* Like hashTypeGetValue() but returns a Redis object, which is useful for |
| 134 | * interaction with the hash type outside t_hash.c. |
no test coverage detected