Major Reve Changes
Greetings dear readers.
The CCP guy (Garthagk) behind the Eve Online API we all use really has a hard task. As the API becomes more and more popular the stress on the webservers hosting the API and the database servers increases. Bossmen and bosswomen may cut the API from us to save resources (that would suck). It's up to us, the community, to do what we can to lessen the load on CCP's servers.
Garthagk provided us with a cacheduntil (Reve::API.cached_until in Reve). Up unil now Reve didn't privde any mechanism for really using this. Sure, you could use just the cached_until if it's just one character. But one of my hopes is that Reve will be used by operators of multi-user sites (like my vapourware evedb.info) that will aggregate many users' data. Cached_until isn't enough.
Enter the protected method Reve::API#compute_hash. (As of revision 22.)
After each API call Reve will compute a hash to represent that request. This will be available through the last_hash. This will tell you what the hash is after the call. But to respect the cached_until it's polite to check the current time against the "Last Call's" cached_until value. The last call will have a hash and that hash will be the key to the cached_until. Each API call now takes a hash for its parameters intead of the old style comma style. Treat the hash as a of transaction ID.
For a simple example let's get the alliances list:
-
require 'reve'
-
api = Reve::API.new
-
alliances = api.alliances
-
p api.last_hash # => 'eve/Alliances.xml.aspx'
-
api.cached_until
For this simple call nothing has changed except the Reve library presents more info for the user. Store cached_until and last_hash in a database.
For the new parameter to get the hash:
-
require 'reve'
-
api = Reve::API.new
-
a_hash = api.alliances :just_hash => true
-
p a_hash # => 'eve/Alliances.xml.aspx'
A complex example:
-
require 'reve'
-
api = Reve::API.new('userid','apikey')
-
sheet = api.character_sheet :characterid => 0123456789
Get the hash:
-
require 'reve'
-
api = Reve::API.new('userid','apikey')
-
h_sheet = api.character_sheet :characterid => 0123456789, :just_hash => true
With luck this post is clear for Reve's users and all you guys will be kind to the API so we have it in the future.

