Jacob Perkins avatar Jacob Perkins committed c6d3fb6

erldis_sync_client:transact/1, erldis 0.0.10

Comments (0)

Files changed (3)

 {application, erldis, [
 	{description, "Erlang Redis application"},
-	{vsn, "0.0.9"},
+	{vsn, "0.0.10"},
 	{registered, [erldis_sup]},
 	{mod, {erldis_app, []}},
 	% TODO: include eunit?

ebin/erldis.appup

-{"0.0.9", [
+{"0.0.10", [
+	{"0.0.9", [{load_module, erldis_sync_client}]},
 	{"0.0.8", [{load_module, erldis_sync_client}]},
 	{"0.0.7", [{load_module, erldis_sync_client}]},
 	{"0.0.6", [
 		{add_module, erldis_sets}
 	]}
 ], [
+	{"0.0.9", [{load_module, erldis_sync_client}]},
 	{"0.0.8", [{load_module, erldis_sync_client}]},
 	{"0.0.7", [{load_module, erldis_sync_client}]},
 	{"0.0.6", [

src/erldis_sync_client.erl

 
 -include("erldis.hrl").
 
--export([scall/2, scall/3, call/2, call/3, stop/1, transact/2, info/1]).
+-export([scall/2, scall/3, call/2, call/3, stop/1, transact/1, transact/2, select/2, info/1]).
 -export([connect/0, connect/1, connect/2, connect/3, connect/4]).
 -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
 		 terminate/2, code_change/3]).
 % stop is synchronous so can be sure that client is shutdown
 stop(Client) -> gen_server:call(Client, disconnect).
 
+transact(F) ->
+	case connect() of
+		{error, Error} -> {error, Error};
+		{ok, Client} -> transact(Client, F)
+	end.
+
 transact(DB, F) when is_integer(DB) ->
 	case connect(DB) of
 		{error, Error} -> {error, Error};
 		exit:Result -> stop(Client), exit(Result)
 	end.
 
+select(Client, DB) ->
+	[ok] = scall(Client, select, [DB]),
+	Client.
+
 info(Client) ->
 	F = fun(Stat) ->
 			case parse_stat(Stat) of
 	connect(Host, Port);
 connect(DB) when is_integer(DB) ->
 	case connect() of
-		{ok, Client} ->
-			[ok] = scall(Client, select, [DB]),
-			{ok, Client};
-		Other ->
-			Other
+		{ok, Client} -> {ok, select(Client, DB)};
+		Other -> Other
 	end.
 
 connect(Host, Port) ->
 
 connect(Host, Port, Options, DB) ->
 	case connect(Host, Port, Options) of
-		{ok, Client} ->
-			[ok] = scall(Client, select, [DB]),
-			{ok, Client};
-		Other ->
-			Other
+		{ok, Client} -> {ok, select(Client, DB)};
+		Other -> Other
 	end.
 
 init([Host, Port]) ->
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.