valkey-glide icon indicating copy to clipboard operation
valkey-glide copied to clipboard

[Inquiry] How to execute lua script using ClusterBatch object?

Open ruslangm opened this issue 6 months ago • 10 comments

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

ruslangm avatar May 28 '25 11:05 ruslangm

@shohamazon can you take a look please?

avifenesh avatar May 28 '25 15:05 avifenesh

Hi @ruslangm 🙂 Currently, glide does not support invoking a script within a Batch, is this something that is blocking you?

shohamazon avatar May 28 '25 15:05 shohamazon

@ruslangm Do you have any update on this issue? Is it still blocking you? Thanks

yipin-chen avatar Aug 12 '25 15:08 yipin-chen

It is not supported now, but you can use custom command as a workaround.

Yury-Fridlyand avatar Aug 20 '25 19:08 Yury-Fridlyand

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.

gabegorelick avatar Aug 20 '25 19:08 gabegorelick

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.

yipin-chen avatar Aug 20 '25 20:08 yipin-chen

@shohamazon any update we could share with the user? Is this one still targeting 2.1?

jamesx-improving avatar Aug 26 '25 00:08 jamesx-improving

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.

jamesx-improving avatar Sep 02 '25 18:09 jamesx-improving

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!

jamesx-improving avatar Sep 02 '25 18:09 jamesx-improving

This issue is inactive for 90 days, hence marked as stale, if the issue is still relevant please perform some activity

github-actions[bot] avatar Dec 02 '25 00:12 github-actions[bot]