|
3 | 3 |
|
4 | 4 | import glide.api.models.GlideString; |
5 | 5 | import glide.api.models.Script; |
| 6 | +import glide.api.models.commands.ScriptDebugMode; |
6 | 7 | import glide.api.models.commands.ScriptOptions; |
7 | 8 | import glide.api.models.commands.ScriptOptionsGlideString; |
8 | 9 | import glide.api.models.configuration.ReadFrom; |
@@ -246,4 +247,173 @@ CompletableFuture<Object> fcallReadOnly( |
246 | 247 | * }</pre> |
247 | 248 | */ |
248 | 249 | CompletableFuture<Object> invokeScript(Script script, ScriptOptionsGlideString options); |
| 250 | + |
| 251 | + /** |
| 252 | + * Executes a read-only Lua script.<br> |
| 253 | + * This command is routed depending on the client's {@link ReadFrom} strategy. |
| 254 | + * |
| 255 | + * @since Valkey 7.0 and above. |
| 256 | + * @see <a href="https://valkey.io/commands/eval_ro/">valkey.io</a> for details. |
| 257 | + * @param script The Lua script to execute. |
| 258 | + * @return A value that depends on the script that was executed. |
| 259 | + * @example |
| 260 | + * <pre>{@code |
| 261 | + * String script = "return 'Hello, World!'"; |
| 262 | + * String result = (String) client.evalReadOnly(script).get(); |
| 263 | + * assert result.equals("Hello, World!"); |
| 264 | + * }</pre> |
| 265 | + */ |
| 266 | + CompletableFuture<Object> evalReadOnly(String script); |
| 267 | + |
| 268 | + /** |
| 269 | + * Executes a read-only Lua script with keys and arguments.<br> |
| 270 | + * This command is routed depending on the client's {@link ReadFrom} strategy. |
| 271 | + * |
| 272 | + * @apiNote When in cluster mode, all <code>keys</code> must map to the same hash slot. |
| 273 | + * @since Valkey 7.0 and above. |
| 274 | + * @see <a href="https://valkey.io/commands/eval_ro/">valkey.io</a> for details. |
| 275 | + * @param script The Lua script to execute. |
| 276 | + * @param keys An array of keys accessed by the script. |
| 277 | + * @param args An array of script arguments. |
| 278 | + * @return A value that depends on the script that was executed. |
| 279 | + * @example |
| 280 | + * <pre>{@code |
| 281 | + * String script = "return {KEYS[1], ARGV[1]}"; |
| 282 | + * Object[] result = (Object[]) client.evalReadOnly(script, new String[]{"key1"}, new String[]{"arg1"}).get(); |
| 283 | + * assert result[0].equals("key1"); |
| 284 | + * assert result[1].equals("arg1"); |
| 285 | + * }</pre> |
| 286 | + */ |
| 287 | + CompletableFuture<Object> evalReadOnly(String script, String[] keys, String[] args); |
| 288 | + |
| 289 | + /** |
| 290 | + * Executes a read-only Lua script.<br> |
| 291 | + * This command is routed depending on the client's {@link ReadFrom} strategy. |
| 292 | + * |
| 293 | + * @since Valkey 7.0 and above. |
| 294 | + * @see <a href="https://valkey.io/commands/eval_ro/">valkey.io</a> for details. |
| 295 | + * @param script The Lua script to execute. |
| 296 | + * @return A value that depends on the script that was executed. |
| 297 | + * @example |
| 298 | + * <pre>{@code |
| 299 | + * GlideString script = gs("return 'Hello, World!'"); |
| 300 | + * GlideString result = (GlideString) client.evalReadOnly(script).get(); |
| 301 | + * assert result.equals(gs("Hello, World!")); |
| 302 | + * }</pre> |
| 303 | + */ |
| 304 | + CompletableFuture<Object> evalReadOnly(GlideString script); |
| 305 | + |
| 306 | + /** |
| 307 | + * Executes a read-only Lua script with keys and arguments.<br> |
| 308 | + * This command is routed depending on the client's {@link ReadFrom} strategy. |
| 309 | + * |
| 310 | + * @apiNote When in cluster mode, all <code>keys</code> must map to the same hash slot. |
| 311 | + * @since Valkey 7.0 and above. |
| 312 | + * @see <a href="https://valkey.io/commands/eval_ro/">valkey.io</a> for details. |
| 313 | + * @param script The Lua script to execute. |
| 314 | + * @param keys An array of keys accessed by the script. |
| 315 | + * @param args An array of script arguments. |
| 316 | + * @return A value that depends on the script that was executed. |
| 317 | + * @example |
| 318 | + * <pre>{@code |
| 319 | + * GlideString script = gs("return {KEYS[1], ARGV[1]}"); |
| 320 | + * Object[] result = (Object[]) client.evalReadOnly(script, new GlideString[]{gs("key1")}, new GlideString[]{gs("arg1")}).get(); |
| 321 | + * assert result[0].equals(gs("key1")); |
| 322 | + * assert result[1].equals(gs("arg1")); |
| 323 | + * }</pre> |
| 324 | + */ |
| 325 | + CompletableFuture<Object> evalReadOnly( |
| 326 | + GlideString script, GlideString[] keys, GlideString[] args); |
| 327 | + |
| 328 | + /** |
| 329 | + * Executes a read-only Lua script by its SHA1 digest.<br> |
| 330 | + * This command is routed depending on the client's {@link ReadFrom} strategy. |
| 331 | + * |
| 332 | + * @since Valkey 7.0 and above. |
| 333 | + * @see <a href="https://valkey.io/commands/evalsha_ro/">valkey.io</a> for details. |
| 334 | + * @param sha1 The SHA1 digest of the script to execute. |
| 335 | + * @return A value that depends on the script that was executed. |
| 336 | + * @example |
| 337 | + * <pre>{@code |
| 338 | + * String sha1 = client.scriptLoad("return 'Hello from SHA!'").get(); |
| 339 | + * String result = (String) client.evalshaReadOnly(sha1).get(); |
| 340 | + * assert result.equals("Hello from SHA!"); |
| 341 | + * }</pre> |
| 342 | + */ |
| 343 | + CompletableFuture<Object> evalshaReadOnly(String sha1); |
| 344 | + |
| 345 | + /** |
| 346 | + * Executes a read-only Lua script by its SHA1 digest with keys and arguments.<br> |
| 347 | + * This command is routed depending on the client's {@link ReadFrom} strategy. |
| 348 | + * |
| 349 | + * @apiNote When in cluster mode, all <code>keys</code> must map to the same hash slot. |
| 350 | + * @since Valkey 7.0 and above. |
| 351 | + * @see <a href="https://valkey.io/commands/evalsha_ro/">valkey.io</a> for details. |
| 352 | + * @param sha1 The SHA1 digest of the script to execute. |
| 353 | + * @param keys An array of keys accessed by the script. |
| 354 | + * @param args An array of script arguments. |
| 355 | + * @return A value that depends on the script that was executed. |
| 356 | + * @example |
| 357 | + * <pre>{@code |
| 358 | + * String sha1 = client.scriptLoad("return {KEYS[1], ARGV[1]}").get(); |
| 359 | + * Object[] result = (Object[]) client.evalshaReadOnly(sha1, new String[]{"key1"}, new String[]{"arg1"}).get(); |
| 360 | + * assert result[0].equals("key1"); |
| 361 | + * assert result[1].equals("arg1"); |
| 362 | + * }</pre> |
| 363 | + */ |
| 364 | + CompletableFuture<Object> evalshaReadOnly(String sha1, String[] keys, String[] args); |
| 365 | + |
| 366 | + /** |
| 367 | + * Executes a read-only Lua script by its SHA1 digest.<br> |
| 368 | + * This command is routed depending on the client's {@link ReadFrom} strategy. |
| 369 | + * |
| 370 | + * @since Valkey 7.0 and above. |
| 371 | + * @see <a href="https://valkey.io/commands/evalsha_ro/">valkey.io</a> for details. |
| 372 | + * @param sha1 The SHA1 digest of the script to execute. |
| 373 | + * @return A value that depends on the script that was executed. |
| 374 | + * @example |
| 375 | + * <pre>{@code |
| 376 | + * GlideString sha1 = client.scriptLoad(gs("return 'Hello from SHA!'")).get(); |
| 377 | + * GlideString result = (GlideString) client.evalshaReadOnly(sha1).get(); |
| 378 | + * assert result.equals(gs("Hello from SHA!")); |
| 379 | + * }</pre> |
| 380 | + */ |
| 381 | + CompletableFuture<Object> evalshaReadOnly(GlideString sha1); |
| 382 | + |
| 383 | + /** |
| 384 | + * Executes a read-only Lua script by its SHA1 digest with keys and arguments.<br> |
| 385 | + * This command is routed depending on the client's {@link ReadFrom} strategy. |
| 386 | + * |
| 387 | + * @apiNote When in cluster mode, all <code>keys</code> must map to the same hash slot. |
| 388 | + * @since Valkey 7.0 and above. |
| 389 | + * @see <a href="https://valkey.io/commands/evalsha_ro/">valkey.io</a> for details. |
| 390 | + * @param sha1 The SHA1 digest of the script to execute. |
| 391 | + * @param keys An array of keys accessed by the script. |
| 392 | + * @param args An array of script arguments. |
| 393 | + * @return A value that depends on the script that was executed. |
| 394 | + * @example |
| 395 | + * <pre>{@code |
| 396 | + * GlideString sha1 = client.scriptLoad(gs("return {KEYS[1], ARGV[1]}")).get(); |
| 397 | + * Object[] result = (Object[]) client.evalshaReadOnly(sha1, new GlideString[]{gs("key1")}, new GlideString[]{gs("arg1")}).get(); |
| 398 | + * assert result[0].equals(gs("key1")); |
| 399 | + * assert result[1].equals(gs("arg1")); |
| 400 | + * }</pre> |
| 401 | + */ |
| 402 | + CompletableFuture<Object> evalshaReadOnly( |
| 403 | + GlideString sha1, GlideString[] keys, GlideString[] args); |
| 404 | + |
| 405 | + /** |
| 406 | + * Sets the debugging mode for executed scripts. |
| 407 | + * |
| 408 | + * @since Redis 3.2 and above. |
| 409 | + * @see <a href="https://valkey.io/commands/script-debug/">valkey.io</a> for details. |
| 410 | + * @param mode The debugging mode to set. |
| 411 | + * @return <code>OK</code>. |
| 412 | + * @example |
| 413 | + * <pre>{@code |
| 414 | + * String response = client.scriptDebug(ScriptDebugMode.YES).get(); |
| 415 | + * assert response.equals("OK"); |
| 416 | + * }</pre> |
| 417 | + */ |
| 418 | + CompletableFuture<String> scriptDebug(ScriptDebugMode mode); |
249 | 419 | } |
0 commit comments