Comments (3)
I'm leaning towards doing it only once and caching it and then maybe have a "expire cache" button somewhere (or cronjob) in case it needs to be refetched (people went to more competitions after registering).
from cubecomp.
Regarding the caching:
You can add caching directly onto Faraday and it'll work like a browser. It would be just a matter of adding expires headers to the API itself. These could be set to at least one day since the WCA export only gets updated weekly. So, performance-wise we would be covered using that solution (speaking of performance: Rust is freaking fast, it renders 35,000 competitors in 60ms (http://178.62.217.148/competitors?q=20), the single endpoint for a competitor (http://178.62.217.148/competitors/2007WEIN01) takes less than 1ms).
This wouldn't help if the API goes down for a long period of time though. The cache would be considered stale, but there would be no data to be fetched.
How would you cache the parsed responses? As attributes on the competitors table?
What I currently have in mind is a read-through cache like so:
class WCACache
def initialize(gateway, cache)
@gateway = gateway
# this could be redis, a file store or MySQL.
# It should be able to handle arbitrary data structures though. Maybe using Marshal?
@cache = cache
end
def psych_sheet(puzzle_id, competitor_ids)
result = @gateway.psych_sheet(puzzle_id, competitor_ids)
@cache.set("psych-sheet-#{puzzle_id}-#{competitor_ids}", result)
result
rescue WCAGateway::ConnectionError
@cache.get("psych-sheet-#{puzzle_id}-#{competitor_ids}") || []
end
end
We would always fetch the most recent results unless the API is down in which case we'd return data from the cache. The cache key would need some work though. As it's currently implemented each new registration will invalidate the entire cache.
from cubecomp.
Rust is freaking fast
I'm not so much concerned about response time but more about network latency... unless I would host the rust thing on the same server of course.
from cubecomp.
Related Issues (20)
- WCA delegate
- Event overview has wrong registration numbers HOT 4
- Confirmation mails marked as spam HOT 5
- Remove "Newcomer"-comment for guest from checklist HOT 2
- Date displayed incorrectly if spread over multiple months
- WCA database script not working on Mac OS X HOT 1
- Bug in Stats HOT 3
- Loading front page with custom domain should only show competitions that use that domain
- Broken CSV export HOT 8
- Competitor comparison not working HOT 4
- Competitor limit for competitions
- Uniformly width for each table at schedule
- Wrong weekday for birthdays HOT 5
- French Flag not displayed HOT 2
- Swiss Nationals: Psych sheet error HOT 3
- Lichtenstein missing as a country HOT 1
- Unnoticed mail delivery failures HOT 1
- Option to partially close registration
- Add support for "other" gender HOT 1
- s/United States/USA HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cubecomp.