Class: Phoenix::Pubsub::Redis

Inherits:
Object
  • Object
show all
Defined in:
lib/phoenix/pubsub.rb

Instance Method Summary collapse

Constructor Details

#initialize(redis_url: 'redis://localhost:6379', phoenix_class: 'Chat.PubSub') ⇒ Redis

Returns a new instance of Redis.



43
44
45
46
# File 'lib/phoenix/pubsub.rb', line 43

def initialize(redis_url: 'redis://localhost:6379', phoenix_class: 'Chat.PubSub')
  @phoenix_class_name = phoenix_class
  @redis = ::Redis.new(url: redis_url)
end

Instance Method Details

#publish(topic, event, payload) ⇒ Object



48
49
50
# File 'lib/phoenix/pubsub.rb', line 48

def publish topic, event, payload
  @redis.publish("phx:Elixir.#{@phoenix_class_name}", serialize_message(topic, event, payload))
end