comparison app/models/tweet.rb @ 143:8a858aec1905

Stringify the cache key
author nanaya <me@nanaya.pro>
date Wed, 13 Dec 2017 06:09:17 +0900
parents 2d873f57f424
children 1925b08153dc
comparison
equal deleted inserted replaced
142:2d873f57f424 143:8a858aec1905
17 17
18 def timeline 18 def timeline
19 initial_config_id = client_config_id 19 initial_config_id = client_config_id
20 20
21 @timeline ||= 21 @timeline ||=
22 Rails.cache.fetch({ :timeline => @twitter_id }, :expires_in => cache_expires_time) do 22 Rails.cache.fetch("timeline:v1:#{@twitter_id}", :expires_in => cache_expires_time) do
23 begin 23 begin
24 timeline = client.user_timeline(@twitter_id, TIMELINE_OPTIONS) 24 timeline = client.user_timeline(@twitter_id, TIMELINE_OPTIONS)
25 rescue Twitter::Error::TooManyRequests 25 rescue Twitter::Error::TooManyRequests
26 @client_config_id += 1 26 @client_config_id += 1
27 27
47 def user 47 def user
48 @user ||= 48 @user ||=
49 if timeline.any? 49 if timeline.any?
50 timeline.first.user 50 timeline.first.user
51 else 51 else
52 Rails.cache.fetch({ :user => @twitter_id }, :expires_in => cache_expires_time) do 52 Rails.cache.fetch("user:v1:#{@twitter_id}", :expires_in => cache_expires_time) do
53 client.user(@twitter_id) 53 client.user(@twitter_id)
54 end 54 end
55 end 55 end
56 end 56 end
57 57