Class: Wayfarer::Frontiers::RedisFrontier Private
- Defined in:
- lib/wayfarer/frontiers/redis_frontier.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A Redis frontier
Instance Attribute Summary
Attributes inherited from Frontier
Instance Method Summary collapse
- #cache(*uris) ⇒ Object private
- #cached?(uri) ⇒ Boolean private
- #current_uris ⇒ Object private
- #free ⇒ Object private
-
#initialize(config) ⇒ RedisFrontier
constructor
private
A new instance of RedisFrontier.
- #stage(*uris) ⇒ Object private
- #staged?(uri) ⇒ Boolean private
- #staged_uris ⇒ Object private
Methods inherited from Frontier
Constructor Details
#initialize(config) ⇒ RedisFrontier
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of RedisFrontier.
10 11 12 13 |
# File 'lib/wayfarer/frontiers/redis_frontier.rb', line 10 def initialize(config) @conn = Redis.new(config.redis_opts) super(config) end |
Instance Method Details
#cache(*uris) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 |
# File 'lib/wayfarer/frontiers/redis_frontier.rb', line 36 def cache(*uris) @conn.sadd(cached_uris_key, uris.map(&:to_s)) if uris.any? end |
#cached?(uri) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
41 42 43 |
# File 'lib/wayfarer/frontiers/redis_frontier.rb', line 41 def cached?(uri) @conn.sismember(cached_uris_key, uri.to_s) end |
#current_uris ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 |
# File 'lib/wayfarer/frontiers/redis_frontier.rb', line 16 def current_uris @conn.smembers(current_uris_key).map { |str| URI(str) } end |
#free ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
46 47 48 49 50 51 52 |
# File 'lib/wayfarer/frontiers/redis_frontier.rb', line 46 def free [current_uris_key, staged_uris_key, cached_uris_key].each do |key| @conn.del(key) end @conn.disconnect! end |
#stage(*uris) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'lib/wayfarer/frontiers/redis_frontier.rb', line 26 def stage(*uris) @conn.sadd(staged_uris_key, uris.map(&:to_s)) if uris.any? end |
#staged?(uri) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 |
# File 'lib/wayfarer/frontiers/redis_frontier.rb', line 31 def staged?(uri) @conn.sismember(staged_uris_key, uri.to_s) end |
#staged_uris ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 |
# File 'lib/wayfarer/frontiers/redis_frontier.rb', line 21 def staged_uris @conn.smembers(staged_uris_key).map { |str| URI(str) } end |