Unless you have a non-prolog redis client, then it would be better to store the dict as a prolog term; if you need to store the dict as a redis hash then you can use a helper predicate like this:
redis_dictset_cmd(Key, Dict, Cmd) :-
redis_array_dict(List,_,Dict),
Cmd =.. [hset|[Key|List]],
format('redis hset cmd is: ~w~n',[Cmd]).
test_hash :-
redis_dictset_cmd(mykey1,_{field11: v1, field12: v2},SetHash1),
redis_dictset_cmd(mykey2,_{field21: v3, field22: v4},SetHash2),
redis( default,
[ multi,
SetHash1,
SetHash2,
exec
]),
show(hashes).
test_prolog_term :-
Dict1 =_{field11: v1, field12: v2},
Dict2 =_{field21: v3, field22: v4},
redis( default,
[ multi,
set(mykey1,Dict1 as prolog),
set(mykey2,Dict2 as prolog),
exec
]),
show(dicts).
show(hashes) :-
redis_get_hash(default, mykey1, Dict1),
redis_get_hash(default, mykey2, Dict2),
print_term(Dict1,[]), nl,
print_term(Dict2,[]).
show(dicts) :-
redis(default, get(mykey1), Dict1),
redis(default, get(mykey2), Dict2),
print_term(Dict1,[]), nl,
print_term(Dict2,[]).
Query:
10 ?- test_hash.
redis hset cmd is: hset(mykey1,field11,v1,field12,v2)
redis hset cmd is: hset(mykey2,field21,v3,field22,v4)
_{field11:v1,field12:v2}
_{field21:v3,field22:v4}
true.
11 ?- test_prolog_term.
_{field11:v1,field12:v2}
_{field21:v3,field22:v4}
true.