Module: Osbourne::ExistingSubscriptions

Included in:
Osbourne
Defined in:
lib/osbourne/existing_subscriptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#existing_subscriptionsObject (readonly)

Returns the value of attribute existing_subscriptions.



5
6
7
# File 'lib/osbourne/existing_subscriptions.rb', line 5

def existing_subscriptions
  @existing_subscriptions
end

Instance Method Details

#clear_subscriptions_for(topic) ⇒ Object



20
21
22
# File 'lib/osbourne/existing_subscriptions.rb', line 20

def clear_subscriptions_for(topic)
  Osbourne.cache.delete("osbourne_existng_subs_for_#{topic.name}")
end

#existing_subscriptions_for(topic) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/osbourne/existing_subscriptions.rb', line 6

def existing_subscriptions_for(topic)
  Osbourne.cache.delete("osbourne_existng_subs_for_#{topic.name}")
  Osbourne.cache.fetch("osbourne_existng_subs_for_#{topic.name}") do
    results = []
    handled = Osbourne.lock.try_with_lock("osbourne_lock_subs_for_#{topic.name}") do
      results = fetch_existing_subscriptions_for(topic)
    end
    return results if handled

    sleep(0.5)
    existing_subscriptions_for(topic)
  end
end