10 ms·
Interesting.. how often do you pull from the db's? Do you think about it as a write-through cache?
by gizzlon 14y ago
Interesting.. how often do you pull from the db's? Do you think about it as a write-through cache?
- benologist 14y agoEvery 30 or 60 seconds + the data's timestamped so it's usually a pretty minimal refresh. It's really just like using any memcached or the built in .net caching rather than a write through one, new data reaches each dyno either via the periodic refresh or when it tries to create that record and finds it already exists. Writes are done immediately and the caches don't get updated because there's 8 - 16 dynos and why bother updating the single dyno that created it. I did originally use redis pub/sub to push out updates to everything but I ended up removing it because it was unnecessary. Here's some example code, it pre-fetches all the leaderboards (not scores) every 30 seconds: http://pastebin.com/asq6eExu http://pastebin.com/asq6eExu Higher up in the same script is the api for the leaderboard data with stuff like: http://pastebin.com/gsfvsZsv http://pastebin.com/gsfvsZsv