My Profile 'Signs with Twitter' applies OAuth Dance, and shows to all the users followed by the current user . And now the real question: It is unnecessary to kill Twitter for this information on every page load. If we want to cache the results of this kind of API call (and provide a method to easily flush that cache) for such a time, how can we go about it? Is this just a question of the return value of the column call of the API call, with the 'completion' column, and when calling the API, the column value is empty or cache_expear & lt; Now he? If so, it seems that it would be better positioned in your model. idea? If you want the cash expired after a certain time, then you probably use Memcached Memcached Allows you to specify an end time for your cache. Once you have configured the railroad to use Memcache as the default cache solution, you can do the following: Which list will cache, in memory, For 1 hour, and the cash is unique to every user, you still have to finish this command manually. Let's say: PS: I think That your attitude of not modeling every user who follows the existing user is perfectly OK. If you want to fully work on these users, then it probably wants to create a different model for Twitter user, but I can not merge user and twitter user because they are probably quite different. For example, a random user can not have authorization in your system and may not be able to log in because a user of your system is following them. # / view / user / shows.ir & Lt; H1 & gt; The users you followed & lt; / H1> & Lt;% = Render: Partial = & gt; 'Indexed user' ,: archive = & gt; @ Current_user.following%>
The following is a virtual feature of the user model.
# /users/models/user.rb def The result is the first, because I am new to Rail (and MVC) I ask: Is this an appropriate abstraction? Should the user 'be adhered to' themselves be modeled?
def The following Rails.cache.fetch ("The following / # {Id} ",: expires_in = & gt; 1.hour) Results = twitter_request_authenticated ('get_following') parse_body (results) end of the list
Rails.cache.delete ("the following / # {id}") # where the user ID is
Comments
Post a Comment