Class: Routemaster::EventIndex
- Inherits:
-
Object
- Object
- Routemaster::EventIndex
- Defined in:
- lib/routemaster/event_index.rb
Instance Method Summary collapse
- #current ⇒ Object
- #increment ⇒ Object
-
#initialize(url, cache: Config.cache_redis) ⇒ EventIndex
constructor
A new instance of EventIndex.
Constructor Details
#initialize(url, cache: Config.cache_redis) ⇒ EventIndex
Returns a new instance of EventIndex.
4 5 6 7 |
# File 'lib/routemaster/event_index.rb', line 4 def initialize(url, cache: Config.cache_redis) @url = url @cache = cache end |
Instance Method Details
#current ⇒ Object
19 20 21 |
# File 'lib/routemaster/event_index.rb', line 19 def current (@cache.hget(_key, 'current_index') || 0).to_i end |
#increment ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/routemaster/event_index.rb', line 9 def increment _node do |cache, key| cache.multi do |m| m.hincrby(key, 'current_index', 1) m.expire(key, Config.cache_expiry) end end self end |