mirror of
https://github.com/btdig/dhtcrawler2.git
synced 2025-01-19 12:41:36 +00:00
fix http cache bug
This commit is contained in:
parent
bb2cbfcc2d
commit
0dcf0854a8
@ -68,8 +68,9 @@ handle_info(timeout, State) ->
|
|||||||
spawn_update(top),
|
spawn_update(top),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
|
||||||
handle_info({enter_cache, Type, Val}, State) ->
|
handle_info({enter_cache, Type, Time, Ret}, State) ->
|
||||||
#state{cache = Cache} = State,
|
#state{cache = Cache} = State,
|
||||||
|
Val = {Time, Ret},
|
||||||
NewCache = gb_trees:enter(Type, Val, Cache),
|
NewCache = gb_trees:enter(Type, Val, Cache),
|
||||||
{noreply, State#state{cache = NewCache}};
|
{noreply, State#state{cache = NewCache}};
|
||||||
|
|
||||||
@ -136,7 +137,7 @@ async_update(Type, From) ->
|
|||||||
Start = now(),
|
Start = now(),
|
||||||
io:format("async update cache ~p start~n", [Type]),
|
io:format("async update cache ~p start~n", [Type]),
|
||||||
Ret = do_update(Type),
|
Ret = do_update(Type),
|
||||||
From ! {enter_cache, Type, Ret},
|
From ! {enter_cache, Type, now(), Ret},
|
||||||
io:format("async update cache ~p done used ~p ms~n",
|
io:format("async update cache ~p done used ~p ms~n",
|
||||||
[Type, timer:now_diff(now(), Start) div 1000]).
|
[Type, timer:now_diff(now(), Start) div 1000]).
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user