Calling custom module command using Lettuce client

68 views
Skip to first unread message

Sindhu Varier

unread,
Nov 2, 2020, 11:41:22 AM11/2/20
to lettuce-redis-client-users
Hi,

I am trying to understand if I can use dispatch and CommandArgs

to call a custom module command that sets a value in a hashmap. Is CommandArgs only for key/value or can it be used to set an entry in a hashmap?

If not, how else can this be done?

Thanks
Sindhu

Mark Paluch

unread,
Nov 3, 2020, 11:55:39 AM11/3/20
to lettuce-redis-client-users
Hi Sindhu, 

Redis accepts commands that consist of a command type (or multiple command keywords) and a list of arguments. CommandArgs doesn't distinguish whether the actual target data type is a map, list, set, …, rather it's an enumeration of arguments. CommandArgs distinguishes only on the argument level between String, byte[], integer/double, keys and values (applying RedisCodec).

Let's take your map example. The command for storing multiple map entries in Redis is HMSET, so this goes something along the lines of:

HMSET key map-field1 map-value1 map-field2 map-value2

Translating to the Lettuce API, you end up with something like:

new Command<>(CommandType.HMSET, …, new CommandArgs<>(StringCodec.UTF8).add("key").add("map-field1").add("map-value1").add("map-field2").add("map-value2"));

Hope this helps.

Cheers, 
Mark

Sindhu Varier

unread,
Nov 4, 2020, 2:48:30 AM11/4/20
to lettuce-redis-client-users
Thanks this helps.
Reply all
Reply to author
Forward
0 new messages