class Routemaster::Dirty::State
Locale prepresentation of the state of an entity.
-
url (string): the entity’s authoritative locator
-
t (datetime, UTC): when the state was last refreshed
Constants
- KEY
Public Class Methods
get(redis, url)
click to toggle source
Given a ‘redis` instance, return
-
a “blank” state for that URL (with time stamp 0), if the state is unknown; or
-
the entity state, if known.
# File lib/routemaster/dirty/state.rb, line 17 def self.get(redis, url) data = redis.get(KEY % url) return new(url, 0) if data.nil? Marshal.load(data) end
Public Instance Methods
save(redis, expiry)
click to toggle source
Given a ‘redis` instance, save the state, expiring after `expiry` seconds.
# File lib/routemaster/dirty/state.rb, line 25 def save(redis, expiry) data = Marshal.dump(self) redis.set(KEY % url, data, ex: expiry) end