我有一个模块,我在ETS表中存储了一些数据 现在我试图过滤迭代ETS表的数据,但总是变空[List]。 (这个匹配每次 - 匹配('$ end_of_table',Acc) - > Acc;)
-module(t).
-export([matching/0]).
matching() -> matching(ets:first(auth), []).
matching('$end_of_table', Acc) -> Acc;
matching(Key, Acc) ->
FromSec = calendar:datetime_to_gregorian_seconds({{2017,1,12}, {11,00,00}}),
ToSec = calendar:datetime_to_gregorian_seconds({{2017,1,12}, {12,00,00}}),
case ets:lookup(auth, Key) of
[{Login, Pass, TTL, Unix, Unix2}] when Unix2 >= FromSec, Unix2 =< ToSec -> NewAcc = [{Login, Pass, TTL, Unix, Unix2}|Acc],
N = ets:next(auth, Key),
matching(N, NewAcc);
_ -> N = ets:next(auth, Key),
matching(N, Acc)
end.
可能是我错误地创建了ETS表?
答案 0 :(得分:0)
找到了答案!
unixtime和 calendar:datetime_to_gregorian_seconds({{2017,1,12},{11,00,00}})不同
所以一切都与匹配相匹配(&#39; $ end_of_table&#39;,Acc) - &gt;度Acc;