Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_TLS=1 -DENABLE_RDMA=1 ..
sudo make install
```

### Other build options

`VALKEY_NO_DEPRECATED` — Disable deprecated names (e.g. `freeReplyObject`). Define this to ensure only the new `valkey`-prefixed names are used.
Comment on lines +67 to +69

@zuiderkwast zuiderkwast May 5, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a make variable like the other build options mentioned above. Can we worth mentioning. How do you specify defines on the command line? Like this?

make `CFLAGS=-DVALKEY_NO_DEPRECATED=1`


## Contributing

Please see [`CONTRIBUTING.md`](https://github.com/valkey-io/libvalkey/blob/main/CONTRIBUTING.md).
6 changes: 3 additions & 3 deletions docs/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ if (reply == NULL) {
} else {
// Handle reply..
}
freeReplyObject(reply);
valkeyFreeReplyObject(reply);
```

Commands will be sent to the cluster node that the client perceives handling the given key.
Expand Down Expand Up @@ -160,14 +160,14 @@ if (valkeyClusterGetReply(cc,&reply) != VALKEY_OK) {
exit(1);
}
// Handle the reply for SET here.
freeReplyObject(reply);
valkeyFreeReplyObject(reply);

if (valkeyClusterGetReply(cc,&reply) != VALKEY_OK) {
fprintf(stderr, "Error reading reply %zu: %s\n", i, c->errstr);
exit(1);
}
// Handle the reply for GET here.
freeReplyObject(reply);
valkeyFreeReplyObject(reply);
```

### Events
Expand Down
1 change: 1 addition & 0 deletions docs/migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The type `sds` is removed from the public API.
### Renamed API functions

* `redisAsyncSetConnectCallbackNC` is renamed to `valkeyAsyncSetConnectCallback`.
* `freeReplyObject` is renamed to `valkeyFreeReplyObject`.

### Removed API functions

Expand Down
12 changes: 6 additions & 6 deletions docs/standalone.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ There are also several flags you can specify when using the `valkeyOptions` help
| `VALKEY_OPT_REUSEADDR` | Tells libvalkey to set the [SO_REUSEADDR](https://man7.org/linux/man-pages/man7/socket.7.html) socket option |
| `VALKEY_OPT_PREFER_IPV4`<br>`VALKEY_OPT_PREFER_IPV6`<br>`VALKEY_OPT_PREFER_IP_UNSPEC` | Informs libvalkey to either prefer IPv4 or IPv6 when invoking [getaddrinfo](https://man7.org/linux/man-pages/man3/gai_strerror.3.html). `VALKEY_OPT_PREFER_IP_UNSPEC` will cause libvalkey to specify `AF_UNSPEC` in the getaddrinfo call, which means both IPv4 and IPv6 addresses will be searched simultaneously.<br>Libvalkey prefers IPv4 by default. |
| `VALKEY_OPT_NO_PUSH_AUTOFREE` | Tells libvalkey to not install the default RESP3 PUSH handler (which just intercepts and frees the replies). This is useful in situations where you want to process these messages in-band. |
| `VALKEY_OPT_NOAUTOFREEREPLIES` | **ASYNC**: tells libvalkey not to automatically invoke `freeReplyObject` after executing the reply callback. |
| `VALKEY_OPT_NOAUTOFREEREPLIES` | **ASYNC**: tells libvalkey not to automatically invoke `valkeyFreeReplyObject` after executing the reply callback. |
| `VALKEY_OPT_NOAUTOFREE` | **ASYNC**: Tells libvalkey not to automatically free the `valkeyAsyncContext` on connection/communication failure, but only if the user makes an explicit call to `valkeyAsyncDisconnect` or `valkeyAsyncFree` |
| `VALKEY_OPT_MPTCP` | Tells libvalkey to use multipath TCP (MPTCP). Note that only when both the server and client are using MPTCP do they establish an MPTCP connection between them; otherwise, they use a regular TCP connection instead. |

Expand All @@ -97,7 +97,7 @@ if (reply == NULL) {
}

printf("New value of 'counter' is %lld\n", reply->integer);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);
```

If you need to deliver binary safe strings to the server, you can use the `%b` format specifier which requires you to pass the length as well.
Expand Down Expand Up @@ -144,12 +144,12 @@ When a `valkeyReply` is returned, you should test the `valkeyReply->type` field

### Disconnecting/cleanup

When libvalkey returns non-null `valkeyReply` struts you are responsible for freeing them with `freeReplyObject`. In order to disconnect and free the context simply call `valkeyFree`.
When libvalkey returns non-null `valkeyReply` struts you are responsible for freeing them with `valkeyFreeReplyObject`. In order to disconnect and free the context simply call `valkeyFree`.

```c
valkeyReply *reply = valkeyCommand(ctx, "set %s %s", "foo", "bar");
// Error handling ...
freeReplyObject(reply);
valkeyFreeReplyObject(reply);

// Disconnect and free context
valkeyFree(ctx);
Expand Down Expand Up @@ -181,7 +181,7 @@ for (size_t i = 0; i < 100000; i++) {
}

printf("INCRBY key:%zu => %lld\n", i, reply->integer);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);
}
```

Expand All @@ -193,7 +193,7 @@ assert(reply != NULL && !c->err);

while (valkeyGetReply(c, (void**)&reply) == VALKEY_OK) {
// Do something with the message...
freeReplyObject(reply);
valkeyFreeReplyObject(reply);
}
```

Expand Down
6 changes: 3 additions & 3 deletions examples/blocking-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static void assertReplyAndFree(valkeyContext *context, valkeyReply *reply, int t
panicAbort("Expected reply type %d but got type %d", type, reply->type);
}

freeReplyObject(reply);
valkeyFreeReplyObject(reply);
}

/* Switch to the RESP3 protocol and enable client tracking */
Expand All @@ -71,7 +71,7 @@ static void enableClientTracking(valkeyContext *c) {
exit(-1);
}

freeReplyObject(reply);
valkeyFreeReplyObject(reply);

/* Enable client tracking */
reply = valkeyCommand(c, "CLIENT TRACKING ON");
Expand All @@ -95,7 +95,7 @@ void pushReplyHandler(void *privdata, void *r) {
printf("pushReplyHandler(): INVALIDATE '%s' (invalidation count: %d)\n",
reply->element[1]->element[0]->str, *invalidations);

freeReplyObject(reply);
valkeyFreeReplyObject(reply);
}

/* We aren't actually freeing anything here, but it is included to show that we can
Expand Down
18 changes: 9 additions & 9 deletions examples/blocking-tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,40 +58,40 @@ int main(int argc, char **argv) {
/* PING server */
reply = valkeyCommand(c, "PING");
printf("PING: %s\n", reply->str);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);

/* Set a key */
reply = valkeyCommand(c, "SET %s %s", "foo", "hello world");
printf("SET: %s\n", reply->str);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);

/* Set a key using binary safe API */
reply = valkeyCommand(c, "SET %b %b", "bar", (size_t)3, "hello", (size_t)5);
printf("SET (binary API): %s\n", reply->str);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);

/* Try a GET and two INCR */
reply = valkeyCommand(c, "GET foo");
printf("GET foo: %s\n", reply->str);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);

reply = valkeyCommand(c, "INCR counter");
printf("INCR counter: %lld\n", reply->integer);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);
/* again ... */
reply = valkeyCommand(c, "INCR counter");
printf("INCR counter: %lld\n", reply->integer);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);

/* Create a list of numbers, from 0 to 9 */
reply = valkeyCommand(c, "DEL mylist");
freeReplyObject(reply);
valkeyFreeReplyObject(reply);
for (j = 0; j < 10; j++) {
char buf[64];

snprintf(buf, 64, "%u", j);
reply = valkeyCommand(c, "LPUSH mylist element-%s", buf);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);
}

/* Let's check what we have inside the list */
Expand All @@ -101,7 +101,7 @@ int main(int argc, char **argv) {
printf("%u) %s\n", j, reply->element[j]->str);
}
}
freeReplyObject(reply);
valkeyFreeReplyObject(reply);

/* Disconnects and frees the context */
valkeyFree(c);
Expand Down
20 changes: 10 additions & 10 deletions examples/blocking.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static void example_argv_command(valkeyContext *c, size_t n) {
printf("%s reply: %lld\n", argv[0], reply->integer);
}

freeReplyObject(reply);
valkeyFreeReplyObject(reply);

/* Clean up */
for (size_t i = 2; i < (n + 2); i++) {
Expand Down Expand Up @@ -93,40 +93,40 @@ int main(int argc, char **argv) {
/* PING server */
reply = valkeyCommand(c, "PING");
printf("PING: %s\n", reply->str);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);

/* Set a key */
reply = valkeyCommand(c, "SET %s %s", "foo", "hello world");
printf("SET: %s\n", reply->str);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);

/* Set a key using binary safe API */
reply = valkeyCommand(c, "SET %b %b", "bar", (size_t)3, "hello", (size_t)5);
printf("SET (binary API): %s\n", reply->str);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);

/* Try a GET and two INCR */
reply = valkeyCommand(c, "GET foo");
printf("GET foo: %s\n", reply->str);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);

reply = valkeyCommand(c, "INCR counter");
printf("INCR counter: %lld\n", reply->integer);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);
/* again ... */
reply = valkeyCommand(c, "INCR counter");
printf("INCR counter: %lld\n", reply->integer);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);

/* Create a list of numbers, from 0 to 9 */
reply = valkeyCommand(c, "DEL mylist");
freeReplyObject(reply);
valkeyFreeReplyObject(reply);
for (j = 0; j < 10; j++) {
char buf[64];

snprintf(buf, 64, "%u", j);
reply = valkeyCommand(c, "LPUSH mylist element-%s", buf);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);
}

/* Let's check what we have inside the list */
Expand All @@ -136,7 +136,7 @@ int main(int argc, char **argv) {
printf("%u) %s\n", j, reply->element[j]->str);
}
}
freeReplyObject(reply);
valkeyFreeReplyObject(reply);

/* See function for an example of valkeyCommandArgv */
example_argv_command(c, 10);
Expand Down
2 changes: 1 addition & 1 deletion examples/cluster-clientside-caching-async.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void modifyKey(const char *key, const char *value) {

valkeyReply *reply = valkeyClusterCommand(cc, "SET %s %s", key, value);
assert(reply != NULL);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);

valkeyClusterFree(cc);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/cluster-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ int main(void) {

valkeyReply *reply = valkeyClusterCommand(cc, "SET %s %s", "key", "value");
printf("SET: %s\n", reply->str);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);

valkeyReply *reply2 = valkeyClusterCommand(cc, "GET %s", "key");
printf("GET: %s\n", reply2->str);
freeReplyObject(reply2);
valkeyFreeReplyObject(reply2);

valkeyClusterFree(cc);
return 0;
Expand Down
4 changes: 2 additions & 2 deletions examples/cluster-tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ int main(void) {
exit(-1);
}
printf("SET: %s\n", reply->str);
freeReplyObject(reply);
valkeyFreeReplyObject(reply);

valkeyReply *reply2 = valkeyClusterCommand(cc, "GET %s", "key");
if (!reply2) {
printf("Reply missing: %s\n", cc->errstr);
exit(-1);
}
printf("GET: %s\n", reply2->str);
freeReplyObject(reply2);
valkeyFreeReplyObject(reply2);

valkeyClusterFree(cc);
valkeyFreeTLSContext(tls);
Expand Down
7 changes: 6 additions & 1 deletion include/valkey/valkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,12 @@ typedef struct valkeyReply {
LIBVALKEY_API valkeyReader *valkeyReaderCreate(void);

/* Function to free the reply objects hivalkey returns by default. */
LIBVALKEY_API void freeReplyObject(void *reply);
LIBVALKEY_API void valkeyFreeReplyObject(void *reply);

/* Deprecated name, provided for backward compatibility. */
#ifndef VALKEY_NO_DEPRECATED
#define freeReplyObject valkeyFreeReplyObject
#endif

/* Functions to format a command according to the protocol. */
LIBVALKEY_API int valkeyvFormatCommand(char **target, const char *format, va_list ap);
Expand Down
4 changes: 2 additions & 2 deletions src/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ valkeyAsyncContext *valkeyAsyncConnectWithOptions(const valkeyOptions *options)
valkeyContext *c;
valkeyAsyncContext *ac;

/* Clear any erroneously set sync callback and flag that we don't want to
* use freeReplyObject by default. */
/* Clear any erroneously set sync callback, and flag that we don't want to
* use valkeyFreeReplyObject by default. */
myOptions.push_cb = NULL;
myOptions.options |= VALKEY_OPT_NO_PUSH_AUTOFREE;

Expand Down
Loading
Loading