![]() |
RedisX v1.0
A simple, light-weight Redis database client
|
Functions | |
| int | redisxAppendRESP (RESP *resp, RESP *part) |
| int | redisxCheckDestroyRESP (RESP *resp, enum resp_type expectedType, int expectedSize) |
| int | redisxCheckRESP (const RESP *resp, enum resp_type expectedType, int expectedSize) |
| RESP * | redisxCopyOfRESP (const RESP *resp) |
| void | redisxDestroyRESP (RESP *resp) |
| RedisMap * | redisxGetKeywordEntry (const RESP *map, const char *key) |
| RedisMap * | redisxGetMapEntry (const RESP *map, const RESP *key) |
| boolean | redisxHasComponents (const RESP *r) |
| boolean | redisxIsArrayType (const RESP *r) |
| boolean | redisxIsEqualRESP (const RESP *a, const RESP *b) |
| boolean | redisxIsMapType (const RESP *r) |
| boolean | redisxIsScalarType (const RESP *r) |
| boolean | redisxIsStringType (const RESP *r) |
| void | redisxPrintDelimited (const RESP *resp, const char *delim, const char *groupPrefix) |
| int | redisxPrintJSON (const char *name, const RESP *resp) |
| int | redisxPrintRESP (const RESP *resp) |
| char * | redisxRESP2JSON (const char *name, const RESP *resp) |
| XField * | redisxRESP2XField (const char *name, const RESP *resp) |
| int | redisxSplitText (RESP *resp, char **text) |
A set of utilities for handling RESP responses from a Redis / Valkey server.
Appends a part to an existing RESP of the same type, before discarding the part.
| [in,out] | resp | The RESP to which the part is appended |
| part | The part, which is destroyed after the content is appended to the first RESP argument. |
References RESP::n, REDIS_UNEXPECTED_RESP, redisxDestroyRESP(), redisxIsArrayType(), redisxIsMapType(), redisxIsScalarType(), RESP3_NULL, RESP::type, RESP::value, x_error(), X_FAILURE, X_NULL, and X_SUCCESS.
Like redisxCheckRESP(), but it also destroys the RESP in case of an error.
| resp | Pointer to the RESP structure from Redis. |
| expectedType | The RESP type expected (e.g. RESP_ARRAY) or 0 if not checking type. |
| expectedSize | The expected size of the RESP (array or bytes) or <=0 to skip checking |
References redisxCheckRESP(), and redisxDestroyRESP().
Checks a Redis RESP for NULL values or unexpected values.
| resp | Pointer to the RESP structure from Redis. |
| expectedType | The RESP type expected (e.g. RESP_ARRAY) or 0 if not checking type. |
| expectedSize | The expected size of the RESP (array or bytes) or <=0 to skip checking |
or the error returned in resp->n.
References RESP::n, REDIS_MIGRATING, REDIS_MOVED, REDIS_NULL, REDIS_UNEXPECTED_RESP, redisxClusterIsMigrating(), redisxClusterMoved(), RESP3_BOOLEAN, RESP3_NULL, RESP_INT, RESP::type, RESP::value, x_error(), X_FAILURE, X_NULL, and X_SUCCESS.
Creates an independent deep copy of the RESP, which shares no references with the original.
| resp | The original RESP data structure (it may be NULL). |
References RedisMap::key, RESP::n, redisxCopyOfRESP(), RESP3_ATTRIBUTE, RESP3_BIG_NUMBER, RESP3_BLOB_ERROR, RESP3_DOUBLE, RESP3_MAP, RESP3_PUSH, RESP3_SET, RESP3_VERBATIM_STRING, RESP_ARRAY, RESP_BULK_STRING, RESP_ERROR, RESP_SIMPLE_STRING, RESP::type, RESP::value, and RedisMap::value.
| void redisxDestroyRESP | ( | RESP * | resp | ) |
Frees up the resources used by a RESP structure that was dynamically allocated. The call will segfault if the same RESP is destroyed twice or if the argument is a static allocation.
| resp | Pointer to the RESP structure to be destroyed, which may be NULL (no action taken). |
References RedisMap::key, RESP::n, redisxDestroyRESP(), RESP3_ATTRIBUTE, RESP3_MAP, RESP3_PUSH, RESP3_SET, RESP_ARRAY, RESP::type, RESP::value, and RedisMap::value.
Retrieves a entry, by its string keyword, from a map-type RESP data structure.
| map | The map-type REST data structure containing a dictionary |
| key | The string keyword to match |
References RedisMap::key, RESP::n, redisxIsMapType(), redisxIsStringType(), and RESP::value.
Retrieves a keyed entry from a map-type RESP data structure.
| map | The map-type REST data structure containing a dictionary |
| key | The RESP key to match |
References RedisMap::key, RESP::n, redisxIsMapType(), RESP::type, and RESP::value.
Checks if a RESP has subcomponents, such as arrays or maps (dictionaries).
| r | Pointer to a RESP data structure |
References FALSE, RESP::n, redisxIsArrayType(), and redisxIsMapType().
Checks if a RESP holds an array of RESP pointers, and whose value can be cast to (RESP **) to use.
| r | Pointer to a RESP data structure |
RESP * pointers, or else FALSE (0).References FALSE, RESP3_PUSH, RESP3_SET, RESP_ARRAY, TRUE, and RESP::type.
Checks if two RESP are equal, that is they hold the same type of data, have the same 'n' value, and the values match byte-for-byte, or are both NULL.
References FALSE, RESP::n, TRUE, RESP::type, and RESP::value.
Checks if a RESP holds a dictionary, and whose value can be cast to (RedisMap *) to use.
| r | Pointer to a RESP data structure |
References FALSE, RESP3_ATTRIBUTE, RESP3_MAP, TRUE, and RESP::type.
Checks if a RESP holds a scalar type value, such as an integer, a boolean or a double-precision value, or a null value.
| r | Pointer to a RESP data structure |
References FALSE, RESP3_BOOLEAN, RESP3_DOUBLE, RESP3_NULL, RESP_INT, TRUE, and RESP::type.
Checks if a RESP holds a string type value, whose value can be cast to (char *) to use.
| r | Pointer to a RESP data structure |
References FALSE, RESP3_BIG_NUMBER, RESP3_BLOB_ERROR, RESP3_VERBATIM_STRING, RESP_BULK_STRING, RESP_ERROR, RESP_SIMPLE_STRING, TRUE, and RESP::type.
| void redisxPrintDelimited | ( | const RESP * | resp, |
| const char * | delim, | ||
| const char * | groupPrefix | ||
| ) |
Prints a RESP in raw form using delimiters only.
| resp | Pointer to a RESP (it may be NULL) |
| delim | Delimiter between elements |
| groupPrefix | Prefix in front of arrays and maps |
References RESP::n, redisxPrintDelimited(), RESP3_ATTRIBUTE, RESP3_BIG_NUMBER, RESP3_BLOB_ERROR, RESP3_DOUBLE, RESP3_MAP, RESP3_NULL, RESP3_PUSH, RESP3_SET, RESP3_VERBATIM_STRING, RESP_ARRAY, RESP_BULK_STRING, RESP_ERROR, RESP_INT, RESP_SIMPLE_STRING, RESP::type, and RESP::value.
| int redisxPrintJSON | ( | const char * | name, |
| const RESP * | resp | ||
| ) |
Prints a RESP as a JSON fragmen to the standard output with the specified name
References redisxRESP2JSON(), and X_SUCCESS.
| int redisxPrintRESP | ( | const RESP * | resp | ) |
| char * redisxRESP2JSON | ( | const char * | name, |
| const RESP * | resp | ||
| ) |
Converts a RESP to the xchange representation as an appropriate XField.
| name | The name to assign to the field |
| resp | The RESP data to convert |
References redisxRESP2XField(), and xjsonFieldToString().
Converts a RESP to the xchange representation as an appropriate XField.
| name | The name to assign to the field |
| resp | The RESP data to convert |
References RESP::n, RESP3_ATTRIBUTE, RESP3_BIG_NUMBER, RESP3_BLOB_ERROR, RESP3_BOOLEAN, RESP3_DOUBLE, RESP3_MAP, RESP3_NULL, RESP3_PUSH, RESP3_SET, RESP3_VERBATIM_STRING, RESP_ARRAY, RESP_BULK_STRING, RESP_ERROR, RESP_INT, RESP_SIMPLE_STRING, RESP::type, RESP::value, X_UNKNOWN, xCreateBooleanField(), xCreateDoubleField(), xCreateIntField(), xCreateScalarField(), and xCreateStringField().
| int redisxSplitText | ( | RESP * | resp, |
| char ** | text | ||
| ) |
Splits the string value of a RESP into two components, by terminating the first component with a null byte and optionally returning the remaining part and length in the output parameters. Only RESP_ERROR RESP_BLOB_ERROR and RESP_VERBATIM_STRING types can be split this way. All others will return REDIS_UNEXPECTED_RESP.
| resp | The input RESP. | |
| [out] | text | (optional) pointer in which to return the start of the remnant text component. |
References RESP::n, REDIS_UNEXPECTED_RESP, RESP3_BLOB_ERROR, RESP3_VERBATIM_STRING, RESP_ERROR, RESP::type, RESP::value, x_error(), X_NULL, and X_PARSE_ERROR.