Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added simple example for pattern subscribe.

  • Loading branch information...
commit 95b7669fa005a902adba2fd3c8b39d6a1b1b81b1 1 parent 01469e3
@pmembrey pmembrey authored
Showing with 18 additions and 0 deletions.
  1. +18 −0 src/eredis_sub.erl
View
18 src/eredis_sub.erl
@@ -18,6 +18,8 @@
-export([receiver/1, sub_example/0, pub_example/0]).
+-export([psub_example/0,ppub_example/0]).
+
%%
%% PUBLIC API
%%
@@ -161,7 +163,23 @@ sub_example() ->
end),
{Sub, Receiver}.
+psub_example() ->
+ {ok, Sub} = start_link(),
+ Receiver = spawn_link(fun () ->
+ controlling_process(Sub),
+ psubscribe(Sub, [<<"foo*">>]),
+ receiver(Sub)
+ end),
+ {Sub, Receiver}.
+
pub_example() ->
{ok, P} = eredis:start_link(),
eredis:q(P, ["PUBLISH", "foo", "bar"]),
eredis_client:stop(P).
+
+ppub_example() ->
+ {ok, P} = eredis:start_link(),
+ eredis:q(P, ["PUBLISH", "foo123", "bar"]),
+ eredis_client:stop(P).
+
+

0 comments on commit 95b7669

Please sign in to comment.
Something went wrong with that request. Please try again.