Permalink
Browse files

Try caching tweet

  • Loading branch information...
1 parent e074bd2 commit f667c1ee4f41b428e31c46a6cb0ef7b1b6039487 @mwhuss mwhuss committed Feb 9, 2012
Showing with 10 additions and 3 deletions.
  1. +10 −3 nezumi.rb
View
@@ -22,10 +22,17 @@
get '/' do
begin
- tweet = Twitter.user_timeline("nezumiapp").first.text.slice[0..100]
- @twitter_text = tweet.size > 94 ? tweet.slice(0..93) << "..." : tweet
- rescue
+ @twitter_text = settings.cache.get("tweet")
+ unless @twitter_text
+ tweet = Twitter.user_timeline("nezumiapp").first.text
+ @twitter_text = tweet.size > 94 ? tweet.slice(0..93) << "..." : tweet
+ settings.cache.set("tweet", @twitter_text)
+ end
+ rescue Twitter::Error => e
# rate exceeded...by your face!
+ @twitter_text = e.message
+ rescue Dalli::RingError
+ # no memcache
end
haml :iphone
end

0 comments on commit f667c1e

Please sign in to comment.