[Inquiry] How to execute lua script using ClusterBatch object?
Inquiry
Sorry, I checked the documentation and code examples, but it seems I’m missing how to execute Lua scripts using the Java client and the ClusterBatch object.
Language
Java
Language Version
17
Engine Version
Valkey 7.3
Operating System
No response
Additional Technical Information
No response
@shohamazon can you take a look please?
Hi @ruslangm 🙂 Currently, glide does not support invoking a script within a Batch, is this something that is blocking you?
@ruslangm Do you have any update on this issue? Is it still blocking you? Thanks
It is not supported now, but you can use custom command as a workaround.
you can use custom command as a workaround.
Is there documentation on what this would look like? I think people are coming to this (and similar) issues because it's not obvious from the docs how to implement this.
Also, this affects all clients, not just Java. Perhaps the issue title should be updated to reflect that.
Thank you for your feedback. I have updated the title of this issue. We are currently working on task #3387, and will provide an example of using a custom command.
@shohamazon any update we could share with the user? Is this one still targeting 2.1?
Update: unfortunately we are unable to introduce any code change for this issue within the scope of release 2.1. The only thing we can do for the moment is to update the wiki with the instruction on how to use custom command to achieve this.
Will keep this issue open as the feature request to implement the proper support for EVAL command, and will put it in 2.2 candidate for now. Will do the evaluation and planning after we released 2.1.
At the mean time, here's a quick example of how to use custom command to run Lua script in an Atomic Batch (aka MULTI/EXEC Transaction):
Batch transaction = new Batch(true)
.set("batch-key", "batch-value")
.get("batch-key")
.customCommand(new String[]{"EVAL", "return 'Hello from Lua!'", "0"});
Object[] results = client.exec(transaction, false).get();
System.out.println("Transaction executed:");
System.out.println("SET result: " + results[0]);
System.out.println("GET result: " + results[1]);
System.out.println("EVAL result: " + results[2]);
Hope this could help unblock your work for now @ruslangm @gabegorelick . Feel free to let us know if you have any question. Happy to help!
This issue is inactive for 90 days, hence marked as stale, if the issue is still relevant please perform some activity