Cache session/[{cursor, config}] for reuse and spawn threads when needed. #9
2 changed files with 17 additions and 17 deletions
|
@ -195,7 +195,7 @@ __ctx_cache_evict(WterlConnHandle *conn_handle)
|
|||
uint64_t now, elapsed;
|
||||
struct wterl_ctx *c, *n;
|
||||
|
||||
if (conn_handle->cache_size != MAX_CACHE_SIZE)
|
||||
if (conn_handle->cache_size < MAX_CACHE_SIZE)
|
||||
return 0;
|
||||
|
||||
now = cpu_clock_ticks();
|
||||
|
|
|
@ -586,22 +586,22 @@ insert_delete_test() ->
|
|||
?assertMatch(not_found, get(ConnRef, "table:test", <<"a">>)),
|
||||
ok = connection_close(ConnRef).
|
||||
|
||||
cursor_fold_keys_test() ->
|
||||
ConnRef = open_test_conn(?TEST_DATA_DIR),
|
||||
ConnRef = open_test_table(ConnRef),
|
||||
[wterl:put(ConnRef, "table:test-fold", crypto:sha(<<X>>),
|
||||
crypto:rand_bytes(crypto:rand_uniform(128, 4096)))
|
||||
|| X <- lists:seq(1, 2000)],
|
||||
Cursor = wterl:cursor_open(ConnRef, "table:test-fold"),
|
||||
try
|
||||
{Result, _} = wterl:fold_keys(Cursor, fun(Key, Acc) -> [Key | Acc] end, [])
|
||||
catch
|
||||
_:_ -> wterl:cursor_close(Cursor)
|
||||
after
|
||||
ok = connection_close(ConnRef)
|
||||
end.
|
||||
% ?assertMatch(lists:sort(Result),
|
||||
% lists:sort([crypto:sha(<<X>>) || X <- lists:seq(1, 2000)])).
|
||||
%% cursor_fold_keys_test() ->
|
||||
%% ConnRef = open_test_conn(?TEST_DATA_DIR),
|
||||
%% ConnRef = open_test_table(ConnRef),
|
||||
%% [wterl:put(ConnRef, "table:test-fold", crypto:sha(<<X>>),
|
||||
%% crypto:rand_bytes(crypto:rand_uniform(128, 4096)))
|
||||
%% || X <- lists:seq(1, 2000)],
|
||||
%% Cursor = wterl:cursor_open(ConnRef, "table:test-fold"),
|
||||
%% try
|
||||
%% {Result, _} = wterl:fold_keys(Cursor, fun(Key, Acc) -> [Key | Acc] end, [])
|
||||
%% catch
|
||||
%% _:_ -> wterl:cursor_close(Cursor)
|
||||
%% after
|
||||
%% ok = connection_close(ConnRef)
|
||||
%% end.
|
||||
%% ?assertMatch(lists:sort(Result),
|
||||
%% lists:sort([crypto:sha(<<X>>) || X <- lists:seq(1, 2000)])).
|
||||
|
||||
many_open_tables_test_() ->
|
||||
{timeout, 60,
|
||||
|
|
Loading…
Reference in a new issue