怎么在Erlang中操作Redis
答案:1 悬赏:0 手机版
解决时间 2021-01-29 10:59
- 提问者网友:不要迷恋哥
- 2021-01-28 14:28
怎么在Erlang中操作Redis
最佳答案
- 五星知识达人网友:雾月
- 2021-01-28 15:49
用ERedis:下载和编译:
cd eredis./rebar compile在console中使用:
erl -pa ebin/{ok, C} = eredis:start_link().{ok, <<"OK">>} = eredis:q(C, ["SET", "foo", "bar"]).{ok, <<"bar">>} = eredis:q(C, ["GET", "foo"]).
在模块中使用:
[plain] view plain copy
save_order_id({Pid, DynData}) ->
{ok, Rds} = eredis:start_link(),
{_,Val} = ts_dynvars:lookup(order_id, DynData),
Id = binary_to_list(Val),
{ok, _} = eredis:q(Rds, ["RPUSH", "order_list", Id]).
get_order_id({Pid, DynData}) ->
{ok, Rds} = eredis:start_link(),
{ok, Id} = eredis:q(Rds, ["LPOP", "order_list"]),
Id.
cd eredis./rebar compile在console中使用:
erl -pa ebin/{ok, C} = eredis:start_link().{ok, <<"OK">>} = eredis:q(C, ["SET", "foo", "bar"]).{ok, <<"bar">>} = eredis:q(C, ["GET", "foo"]).
在模块中使用:
[plain] view plain copy
save_order_id({Pid, DynData}) ->
{ok, Rds} = eredis:start_link(),
{_,Val} = ts_dynvars:lookup(order_id, DynData),
Id = binary_to_list(Val),
{ok, _} = eredis:q(Rds, ["RPUSH", "order_list", Id]).
get_order_id({Pid, DynData}) ->
{ok, Rds} = eredis:start_link(),
{ok, Id} = eredis:q(Rds, ["LPOP", "order_list"]),
Id.
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯