anchor.diff:              Err
       end.
   
  +-spec store(channel()) -> any().
  +store(#channel{id=ChannelId, flags=Flags, name=Name}) ->
  +    redis_helper:store_channel(ChannelId, Name, flags_to_binary(Flags)).
  +
  +-spec cache(id(), name(), flags()) -> channel().
  +cache(ChannelId, Name, Flags)
  +  when is_integer(ChannelId),
  +       is_binary(Name),
  +       is_list(Flags) ->
  +    Chan = #channel{id=ChannelId,
  +                    name=Name,
  +                    flags=Flags},
  +    true = ets:insert(channels, Chan),
  +    Chan.
  +
  +-spec flags_to_binary(flags()) -> binary().
  +flags_to_binary(Flags) when is_list(Flags) ->
  +    Str = string:join([ atom_to_list(Flag) || Flag <- lists:usort(Flags) ],
  +                      ":"),
  +    iolist_to_binary(Str).
  +
  +-spec binary_to_flags(binary()) -> flags().
  +binary_to_flags(Str) when is_binary(Str) ->
  +    [ case Flag of
  +          <<"no_tail">> -> no_tail;
  +          <<"no_redis">> -> no_redis
  +      end || Flag <- binary:split(Str, <<":">>) ].
  +
   delete(ChannelId) when is_integer(ChannelId) ->
       case lookup(ChannelId) of
           undefined ->
  
positive.code:          ,can_add_drain/1
          ]).
  
  -compile({no_auto_import,[whereis/1]}).
  
  -include("logplex.hrl").
  -include("logplex_logging.hrl").
  
  -type id() :: integer().
  -export_type([id/0]).
  
  register({channel, ChannelId} = C)
    when is_integer(ChannelId) ->
  
negative.code: 
  lookup(ChannelId) when is_integer(ChannelId) ->
      case ets:lookup(channels, ChannelId) of
          [Channel = #channel{}] -> Channel;
          _ -> undefined
      end.
  
  lookup_flag(ChannelId, Flag) when Flag =:= no_tail;
                                    Flag =:= no_redis ->
      try
          Flags =ets:lookup_element(channels, ChannelId, #channel.flags),
          lists:member(Flag, Flags)
      catch
          error:badarg ->
              not_found
      end.
  
  lookup_flags(ChannelId) when is_integer(ChannelId) ->
      try ets:lookup_element(channels, ChannelId, #channel.flags)
      catch
          error:badarg ->
              not_found
      end.
  
  lookup_tokens(ChannelId) when is_integer(ChannelId) ->
  