Cache session/[{cursor, config}] for reuse and spawn threads when needed. #9

Merged
gburd merged 30 commits from gsb-ctx-cache into master 2013-07-03 12:31:15 +00:00
2 changed files with 17 additions and 17 deletions
Showing only changes of commit 450299dc2d - Show all commits

View file

@ -195,7 +195,7 @@ __ctx_cache_evict(WterlConnHandle *conn_handle)
uint64_t now, elapsed; uint64_t now, elapsed;
struct wterl_ctx *c, *n; struct wterl_ctx *c, *n;
if (conn_handle->cache_size != MAX_CACHE_SIZE) if (conn_handle->cache_size < MAX_CACHE_SIZE)
return 0; return 0;
now = cpu_clock_ticks(); now = cpu_clock_ticks();

View file

@ -586,22 +586,22 @@ insert_delete_test() ->
?assertMatch(not_found, get(ConnRef, "table:test", <<"a">>)), ?assertMatch(not_found, get(ConnRef, "table:test", <<"a">>)),
ok = connection_close(ConnRef). ok = connection_close(ConnRef).
cursor_fold_keys_test() -> %% cursor_fold_keys_test() ->
ConnRef = open_test_conn(?TEST_DATA_DIR), %% ConnRef = open_test_conn(?TEST_DATA_DIR),
ConnRef = open_test_table(ConnRef), %% ConnRef = open_test_table(ConnRef),
[wterl:put(ConnRef, "table:test-fold", crypto:sha(<<X>>), %% [wterl:put(ConnRef, "table:test-fold", crypto:sha(<<X>>),
crypto:rand_bytes(crypto:rand_uniform(128, 4096))) %% crypto:rand_bytes(crypto:rand_uniform(128, 4096)))
|| X <- lists:seq(1, 2000)], %% || X <- lists:seq(1, 2000)],
Cursor = wterl:cursor_open(ConnRef, "table:test-fold"), %% Cursor = wterl:cursor_open(ConnRef, "table:test-fold"),
try %% try
{Result, _} = wterl:fold_keys(Cursor, fun(Key, Acc) -> [Key | Acc] end, []) %% {Result, _} = wterl:fold_keys(Cursor, fun(Key, Acc) -> [Key | Acc] end, [])
catch %% catch
_:_ -> wterl:cursor_close(Cursor) %% _:_ -> wterl:cursor_close(Cursor)
after %% after
ok = connection_close(ConnRef) %% ok = connection_close(ConnRef)
end. %% end.
% ?assertMatch(lists:sort(Result), %% ?assertMatch(lists:sort(Result),
% lists:sort([crypto:sha(<<X>>) || X <- lists:seq(1, 2000)])). %% lists:sort([crypto:sha(<<X>>) || X <- lists:seq(1, 2000)])).
many_open_tables_test_() -> many_open_tables_test_() ->
{timeout, 60, {timeout, 60,